Telerik UI for Silverlight

The ChartTitle is a content control placed at the top of each chart control. It is used to display any title information regarding the visualized chart.

 

You can specify the content of the default ChartTitle control from XAML or code-behind, like this:

CopyXAML
<telerikChart:RadChart x:Name="radChart">
    <telerikChart:RadChart.DefaultView>
        <telerikCharting:ChartDefaultView>
            <telerikCharting:ChartDefaultView.ChartTitle>

                <telerikCharting:ChartTitle Content="Monthly Sales for 2009" HorizontalAlignment="Center"/>

            </telerikCharting:ChartDefaultView.ChartTitle>
        </telerikCharting:ChartDefaultView>
    </telerikChart:RadChart.DefaultView>
</telerikChart:RadChart>
CopyC#
radChart.DefaultView.ChartTitle.Content = "Monthly Sales for 2009";
CopyVB.NET
radChart.DefaultView.ChartTitle.Content = "Monthly Sales for 2009"

Since ChartTitle is a content control, you can set as its content not only textual data but also any other type of controls. The following example demonstrates how to create custom chart title with TextBlock in a Border control.

CopyXAML
<telerikChart:RadChart>
    <telerikChart:RadChart.DefaultView>
        <telerikCharting:ChartDefaultView>
            <telerikCharting:ChartDefaultView.ChartTitle>

                <telerikCharting:ChartTitle HorizontalAlignment="Center">
                    <Border BorderBrush="LightBlue" CornerRadius="5" BorderThickness="2">
                        <TextBlock Text="Monthly Sales for 2009" />
                    </Border>
                </telerikCharting:ChartTitle>

            </telerikCharting:ChartDefaultView.ChartTitle>
        </telerikCharting:ChartDefaultView>
    </telerikChart:RadChart.DefaultView>
</telerikChart:RadChart>
CopyC#
Telerik.Windows.Controls.RadChart radChart = new Telerik.Windows.Controls.RadChart();
....
Border border = new Border();
border.BorderThickness = new Thickness( 2 );
border.CornerRadius = new CornerRadius( 5 );
border.BorderBrush = new SolidColorBrush( Color.FromArgb( 255, 173, 216, 230 ) );
border.Child = new TextBlock(){ Text = "Monthly Sales for 2009" };
radChart.DefaultView.ChartTitle.Content = border;
CopyVB.NET
Dim radChart As New Telerik.Windows.Controls.RadChart()
....
Dim border As New Border()
border.BorderThickness = New Thickness( 2 )
border.CornerRadius = New CornerRadius( 5 )
border.BorderBrush = New SolidColorBrush(Color.FromArgb( 255, 173, 216, 230 ))
border.Child = New TextBlock()
'Set the content of the ChartTitle
radChart.DefaultView.ChartTitle.Content = border

And here is the final result:

 

If you want to learn more about styling the ChartTitle take a look at the Customizing Title topic.

See Also