<Rectangle Width='400'
Margin='30'
Height='300'
Fill='SteelBlue'
Stroke='Orange'
StrokeThickness='15' />
You can exert further control over how the stroke is drawn by modifying additional properties. Let's start by considering the Stroke Dash properties.
Adding dashes to the stroke
The stroke doesn't have to be drawn as a solid entity between two points. You can split the line into a series of dashes with the StrokeDashArray property. As the name implies, StrokeDashArray holds an array of double values. The first value in the DashArray indicates the length of the solid part of the line. The second value in the array indicates the length of the gap. This pattern can continue, add a third value to the array to designate the next solid section length, a fourth value denotes the next gap length and so on. The length is determined by multiplying the array value by the StrokeThickness. In the following example, the lengths are multiples of 15 (solid 30, gap 15,
Requires Free Membership to View
When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to provide a unique online resource for developers, architects and development managers tasked with building and maintaining enterprise applications using Visual Basic, C# and the Microsoft .NET platform.
Hannah Smalltree, Editorial DirectorStrokeThickness='15' StrokeDashArray='2,1,3,2'
Here is a screen shot showing a (1,1) pattern.
Figure 1 - Pattern (1,1)
Here is a screenshot showing a (5,1) pattern.
Figure 2 - Pattern (5,1)
Adding end caps
By default each solid dash segment is drawn with a flat end cap on each end of the dash. You can change the end caps on the dash by setting the StrokeDashCap property. There are four choices available: Flat, Round, Triangle and Square.
Figure 3 - Triangle Dash Cap
This was first published in March 2010