Code Snipets

Silverlight Toolkit Column Series – Display Label on bar (Column Labels) ( datapoint labels )

Posted in Silverlight by mauliksoni on February 14, 2011

Silverlight Toolkit Column Series – Display Label on bar (Column Labels) ( datapoint labels )

Final Output:

Silverlight Toolkit Column Series – Display Label on bar (Column Labels) ( datapoint labels )

Silverlight Toolkit Column Series – Display Label on bar (Column Labels) ( datapoint labels )

<navigation:Page x:Class="SL4Test.Page1" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Page1 Page" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit">
    <Grid x:Name="LayoutRoot"  Margin="0, -17, 0, 0">
        <toolkit:Chart HorizontalAlignment="Left" Margin="124,79,0,0" Name="chart1" Title="Labels on Bar" VerticalAlignment="Top" Height="317" Width="418">
            <toolkit:ColumnSeries DependentValuePath="X" IndependentValuePath="Y">
                <toolkit:ColumnSeries.DataPointStyle>
                    <Style TargetType="toolkit:ColumnDataPoint">
                        <Setter Property="Background" Value="Green"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="toolkit:ColumnDataPoint">
                                    <Grid>
                                        <Rectangle
                                    Fill="{TemplateBinding Background}"
                                    Stroke="Black"/>
                                        <Grid
                                    Background="#aaffffff"
                                    Margin="0 -40 -10 0"
                                    HorizontalAlignment="Right"
                                    VerticalAlignment="Center">
                                            <TextBlock
                                        Text="{TemplateBinding FormattedDependentValue}"
                                        FontWeight="Bold" Width="40"
                                        Margin="2"/>
                                        </Grid>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </toolkit:ColumnSeries.DataPointStyle>
                <toolkit:ColumnSeries.ItemsSource>
                    <PointCollection>
                        <Point>1,10</Point>
                        <Point>2,20</Point>
                        <Point>3,30</Point>
                        <Point>4,40</Point>
                    </PointCollection>
                </toolkit:ColumnSeries.ItemsSource>
            </toolkit:ColumnSeries>
        </toolkit:Chart>
    </Grid>
</navigation:Page>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.