Styling the Chart Legend
The RadChart exposes the LegendStyle property of type Style. It is applied to the ChartLegend control inside the RadChart. You can also style the Legend Items by setting an appropriate style to the LegendItemStyle of the ChartLegend control.
You have two options:
To create an empty styles and set it up on your own.
To copy the default styles of the control and modify it.
This topic will show you how to perform the second one.
Modifying the Default Styles
The ChartLegend and the ChartLegendItem controls are located in the Telerik.Windows.Controls.Charting namespace of the Telerik.Windows.Controls.Charting assembly. In order to use them you have to declare it in XAML:
xmlns:telerikCharting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting" XAMLLanguage Filtered SectionASP.NET
When working in Expression Blend, the namespaces that are needed will be added automatically.
Load your project in Expression Blend and open the User Control that holds the RadChart. You have to use a dummy controls in order to get the default styles. To create one find the ChartLegend or the ChartLegendItem control in the 'Assets' pane and draw one on the art board. In the 'Objects and Timeline' pane select the control, you've drawn and from the menu choose Object -> Edit Style -> Edit a Copy. You will be prompted for the name of the style and where to be placed.
If you choose to define the style in Application, it would be available for the entire application. This allows you to define a style only once and then reuse it where needed.
After clicking 'OK', Expression Blend will generate the default value for the selected Style in the Resources section of your User Control. The properties available for the style will be loaded in the 'Properties' pane and you will be able to modify their default values. You can also edit the generated XAML in the XAML View or in Visual Studio.
To change the fill of the legend item's marker set the MarkerFill property of the CHhrtLegendItem through its Style. For the stroke of the marker use the Stroke property of the ChartLegendItem.
LegendForeground - a brush, that represent the foreground color of the ChartLegend.
LegendBackground - a brush, that represents the background color of the ChartLegend.
LegendBorderBrush - a brush, that represents the border color of the ChartLegend.
LegendBorderThickness - represents the thickness of the border around the ChartLegend.
LegendItemMarkerShape - represents the shape of the marker inside the ChartLegend's item.
ChartLegendStyle - the Style, applied to the ChartLegend control.
LegendForeground - a brush, that represents the foreground color of the ChartLegendItem.
LegendItemMarkerMask - a brush, that represents the background of the mask element for the ChatLegendItem's marker.
LegendItemMarkerMaskStroke - a brush, that represents the border color of the mask element for the ChatLegendItem's marker.
LegendItemMarkerMaskStrokeThickness - that represents the thickness of the border of the mask element for the ChatLegendItem's marker.
LegendItemMarkerMaskStroke - a brush, that represents the opacity mask of the mask element for the ChatLegendItem's marker.
LegendItemMarkerMask - a brush, that represents the background of the secondary mask element for the ChatLegendItem's marker.
ChartLegendItemStyle - the Style, applied to the ChartLegendItem control.
To apply the styles to the real controls, set the ChartLegendItemStyle in the Style for the ChartLegend.
After that set the ChartLegendStyle to the RadChart.
Don't forget to delete the dummy controls, when you finish editing the style.
Here is the XAML, generated for the Styles: