This is a migrated thread and some comments may be shown as answers.

ChartLegend Foreground Color

1 Answer 107 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Nirmal
Top achievements
Rank 1
Nirmal asked on 28 Sep 2009, 05:47 AM
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.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Velin
Telerik team
answered on 01 Oct 2009, 07:48 AM
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.
Tags
Chart
Asked by
Nirmal
Top achievements
Rank 1
Answers by
Velin
Telerik team
Share this question
or