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

    Hai,
        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?

    Thanks.

     

  2. Answer
    Velin
    Admin
    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:
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting" 
     
            <telerik:RadChart x:Name="RadChart1" > 
                <telerik:RadChart.Resources> 
                    <ResourceDictionary> 
                        <ResourceDictionary.MergedDictionaries> 
                            <ResourceDictionary Source="/Telerik.Windows.Controls.Charting;component/Themes/Chart/OfficeBlack/Styles.xaml" /> 
                        </ResourceDictionary.MergedDictionaries> 
                    </ResourceDictionary> 
                    <Style x:Name="LegendItemStyle" BasedOn="{StaticResource Telerik.Windows.Controls.Charting.ChartLegendItem}" TargetType="chart:ChartLegendItem"
                        <Setter Property="Foreground" Value="Black"/> 
                    </Style> 
                </telerik:RadChart.Resources> 
            </telerik:RadChart> 
     
    RadChart1.DefaultView.ChartLegend.LegendItemStyle = this.LegendItemStyle; 

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

    Greetings,
    Velin
    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