'I want to change color of mark on axis in WPF chart
I tried to change color of marks on axis (small lines near numbers), but it didn't change them, instead they just disappear. Here is what I've tried:
<DVC:Chart.Axes>
<DVC:LinearAxis Orientation="X" Title="Id" Foreground="White"/>
<DVC:LinearAxis Orientation="Y" Location="Left" Title="Value" Foreground="White">
<DVC:LinearAxis.MajorTickMarkStyle>
<Style TargetType="Line">
<Setter Property="Control.Background" Value="Green" />
<Setter Property="Control.Foreground" Value="White" />
<Setter Property="Control.BorderBrush" Value="#FFFFA500" />
<Setter Property="Control.BorderThickness" Value="1" />
<Setter Property="Stroke" Value="Green"/>
<Setter Property="StrokeThickness" Value="1"/>
</Style>
</DVC:LinearAxis.MajorTickMarkStyle>
</DVC:LinearAxis>
</DVC:Chart.Axes>
Solution 1:[1]
After a deep 1 hour of searching the solution, I found this:
App.xaml
<Style x:Key="WhiteTickMarkX" TargetType="Line">
<Setter Property="Stroke" Value="White" />
<Setter Property="StrokeThickness" Value="1" />
<Setter Property="X1" Value="-1" />
<Setter Property="X2" Value="6" />
<Setter Property="Fill" Value="White" />
</Style>
<Style x:Key="WhiteTickMarkY" TargetType="Line">
<Setter Property="Stroke" Value="White" />
<Setter Property="StrokeThickness" Value="1" />
<Setter Property="Y1" Value="-1" />
<Setter Property="Y2" Value="6" />
<Setter Property="Fill" Value="White" />
</Style>
X1 and X2 means a horizontal line and Y1 and Y2 means a vertical line.
MajorTickMarkStyle="{StaticResource WhiteTickMarkY}"
MajorTickMarkStyle="{StaticResource WhiteTickMarkX}"
Hope this helps. I've tested on one of my projects, and works fine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | radocz_sandor |