This question is locked. New answers and comments are not allowed.
Hello,
I'm trying to change the Legenditem text color without expression blend.
When the enduser clicks a button the foreground color of the legenditem needs to go black, another button turns it white.
Kind regards,
Jeroen
I'm trying to change the Legenditem text color without expression blend.
When the enduser clicks a button the foreground color of the legenditem needs to go black, another button turns it white.
Kind regards,
Jeroen
3 Answers, 1 is accepted
0
Lancelot
Top achievements
Rank 1
answered on 05 Jun 2012, 10:59 PM
0
Lancelot
Top achievements
Rank 1
answered on 05 Jun 2012, 11:02 PM
Hi Jeroen,
Here is a list of the properties that make up the ChartLegendStyle:
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.
Here is a list of the properties that make up the ChartLegendStyle:
And here is the list of properties that make up the ChartLegendItemStyle:
You can access them from the code behind in a button_click event by iterating through the visual tree for the type Telerik.Windows.Controls.Charting.ChartLegend and then the legend items with Telerik.Windows.Controls.Charting.LegendItem.
Once you iterate for each type, you can then assign a brush to it. in your case it would be
legendItem.Foreground = new SolidcolorBrush(Colors.Black);
and also
legendItem.Foreground = new SolidcolorBrush(Colors.White);
I hope this helps, good luck!
Lancelot
0
Accepted
Hi Jeroen,
There are two possible ways to solve your issue. The first one is to make your own style where you bind the Foreground color to a property in your object.
The other way is what Lancelot suggested - to set it through the visual tree. Here's an example:
Greetings,
There are two possible ways to solve your issue. The first one is to make your own style where you bind the Foreground color to a property in your object.
The other way is what Lancelot suggested - to set it through the visual tree. Here's an example:
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
var legend =
this
.radChart.FindChildByType<Telerik.Windows.Controls.Charting.ChartLegend>();
var legendItems = legend.ItemsSource.Cast<Telerik.Windows.Controls.Charting.ChartLegendItem>();
foreach
(var item
in
legendItems)
{
item.Background =
new
SolidColorBrush(Colors.Red);
}
}
Greetings,
Rosko
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>