ChartLegend Foreground Color

2 posts, 1 answers
  1. Nirmal
    Nirmal avatar
    14 posts
    Member since:
    Dec 2008

    Posted 28 Sep 2009 Link to this post

        I am using 2D pie chart. In that i want to change ChartLegend Foreground color as Black. When i use the below code it doesn't works.

    RadChart.DefaultView.ChartLegend.Foreground =

    new SolidColorBrush(Colors.Black);

    How can i do this?



  2. Answer
    Velin avatar
    391 posts

    Posted 01 Oct 2009 Link to this post

    Hello Nirmal,

    Setting the Foreground property of ChartLegend is applied only to the legend header and not to the items. In order to change the foreground of the legend items, you should extend the default legend item style. Here is how you can do this:
            <telerik:RadChart x:Name="RadChart1" > 
                            <ResourceDictionary Source="/Telerik.Windows.Controls.Charting;component/Themes/Chart/OfficeBlack/Styles.xaml" /> 
                    <Style x:Name="LegendItemStyle" BasedOn="{StaticResource Telerik.Windows.Controls.Charting.ChartLegendItem}" TargetType="chart:ChartLegendItem"
                        <Setter Property="Foreground" Value="Black"/> 
    RadChart1.DefaultView.ChartLegend.LegendItemStyle = this.LegendItemStyle; 

    There is also an online help article on this topic available here.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top