Silverlight DashArray in VB.NET

In this article you will learn about the DashArray in Silverlight.
  • 2059

DashArray: "StrokeDashArray" is the property which we use to define our dashes.  This property indicates the pattern of dashes and spaces between the dashes.  The first value is the width of the dash and the second value is the space between the dashes.

All you need is to define an array of double, size 2, and set the length of the dash as first element and the spacing between to dashes as second element of the array.

Both values are specific to the thickness of the line being drawn, so {1,1} will draw a dotted line (actually a dashed lines with square dashes).

And you want to draw more complex dashed lines, for example like the ones used in technical drawings, you can add to the array other couples of doubles, and draw dash-dot sequences: every even values is the length of dashes, odd values specifies gaps.

Example of StrokDeshArray 

<UserControl x:Class="SilverlightApplication21.MainPage"
    xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
    xmlns:d='http://schemas.microsoft.com/expression/blend/2008' 
    xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006' 
    mc:Ignorable='d' 
    d:DesignWidth='640' 
    d:DesignHeight
='480'>
    <Canvas xmlns="http://schemas.microsoft.com/client/2007">
        <Rectangle
        Stroke="Blue"
        StrokeThickness="8"
        StrokeDashArray="7, 5, 3, 6"
        Canvas.Left="50"
        Canvas.Top="50"
        Width="400"
        Height="400"/> 
    </Canvas>
</
UserControl>

Output WIndow

dash.gif
 

Conclusion

Hope this article will help you to understand the working of  StrokDeshArray in Silverlight.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.