How can I override the AxisLabel Foreground setting within my own App.xaml resource dictionary?
I've tried this but does not work
<Style TargetType="ig:NumericAngleAxis" > <Setter Property="LabelSettings"> <Setter.Value> <ig:AxisLabelSettings Foreground="Blue" FontSize="20"/> </Setter.Value> </Setter> </Style>
Hello,
The easiest way to change the color of the label would be to set it in the LabelSettings of the axis.
<ig:NumericYAxis x:Name="yAxis" > <ig:NumericYAxis.LabelSettings> <ig:AxisLabelSettings Foreground="Red"/> </ig:NumericYAxis.LabelSettings>
In case you would like to have this styled, I can suggest two options:
1. Re-templating the Label. The label text is held by a textblock which can be styled.
<Style TargetType="{x:Type TextBlock}" x:Key="foreColorBlock"> <Setter Property="Foreground" Value="Orange"/> </Style> <ig:CategoryXAxis x:Name="xmCategoryXAxis" ItemsSource="{StaticResource CategoryData1}"> <ig:CategoryXAxis.Label> <DataTemplate> <TextBlock Style="{StaticResource foreColorBlock}" Text="{Binding Item.Category}"/> </DataTemplate> </ig:CategoryXAxis.Label>
More on Axis Label templates can be read on our website here.
2. Define a brush resource and use it as Foreground Color:
<SolidColorBrush x:Key="foregroundBrush" Color="{DynamicResource ColorDefinedByLogic}"/> <ig:CategoryXAxis.LabelSettings> <ig:AxisLabelSettings Foreground="{StaticResource foregroundBrush}"/> </ig:CategoryXAxis.LabelSettings>
Should you have any further questions, please let me know.
Sincerely,Tihomir TonevAssociate Software DeveloperInfragistics
I'm still having trouble dynamically changing the color. My situation is to change from a light theme to dark theme. I do this by removing lighttheme.xaml and adding darktheme.xaml to/from mergeddictionaries in codebehind.
In my XamDataChart control:<ig:CategoryAngleAxis.LabelSettings> <ig:AxisLabelSettings Location="InsideTop" Extent="20" FontSize="12" Foreground="{StaticResource ForegroundSolid}"/> </ig:CategoryAngleAxis.LabelSettings> </ig:CategoryAngleAxis>
In my app.xaml <SolidColorBrush x:Key="ForegroundSolid" Color="{DynamicResource IForegroundSolid}"/>
In darktheme.xaml: <Color x:Key="IForegroundSolid">Blue</Color>
In lighttheme.xaml: <Color x:Key="IForegroundSolid">Red</Color>