Title: Use a custom dash pattern with WPF and XAML in C#
My post Render dashed lines in a WPF program using C# explains how a WPF program can use C# code to render lines with a custom dash pattern onto a bitmap. This post shows how to use a custom dash pattern min XAML code.
The key is to use a StrokeDashArray property to define a line's dash pattern. This program uses the following code to draw its curve.
<Path Stroke="Red" StrokeThickness="5"
Data="M 175,10 C -100,150 400,200 70,30">
The custom dash pattern 10,1,1,1 means the line should draw 10 units, skip 1 unit, draw 1 unit, skip 1 unit, and then repeat.
Note that the units are equal to the width of the line. In this example, the line is 5 pixels wide so each unit is 5 pixels. that means this custom dash pattern makes the line draw 50 pixels, skip 5 pixels, draw 5 pixels, skip 5 pixels, and repeat.
Download the example to experiment with it and to see additional details.