This sample demonstrate how to customize the axis grid lines in WPF chart.
The WPF Chart provides support to customize the axis grid lines with the help of the MajorGridLineStyle, MinorGridLineStyle, MajorTickLineStyle, and MinorTickLineStyle properties of the chart axis.
These properties are of type "Style," which means you can customize the axis grid lines by changing the value of line properties such as Stroke, StrokeThickness, and StrokeDashArray.
For example, you can set the stroke color of the major grid lines to green and the stroke thickness to 2, like this:
[XAML]
<chart:NumericalAxis>
<chart:NumericalAxis.MajorGridLineStyle>
<Style TargetType="Line">
<Setter Property="StrokeThickness" Value="2"/>
<Setter Property="Stroke" Value="Green"/>
</Style>
</chart:NumericalAxis.MajorGridLineStyle>
</chart:NumericalAxis>
You can also use the StrokeDashArray property to set the line style to a dashed pattern like this:
[XAML]
<chart:NumericalAxis>
<chart:NumericalAxis.MinorGridLineStyle>
<Style TargetType="Line">
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="Stroke" Value="Blue"/>
<Setter Property="StrokeDashArray" Value="3,3"/>
</Style>
</chart:NumericalAxis.MinorGridLineStyle>
</chart:NumericalAxis>
If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.