DashStyle.Dashes Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the collection of dashes and gaps in this DashStyle.
public:
property System::Windows::Media::DoubleCollection ^ Dashes { System::Windows::Media::DoubleCollection ^ get(); void set(System::Windows::Media::DoubleCollection ^ value); };
public System.Windows.Media.DoubleCollection Dashes { get; set; }
member this.Dashes : System.Windows.Media.DoubleCollection with get, set
Public Property Dashes As DoubleCollection
Property Value
The collection of dashes and gaps. The default is an empty DoubleCollection.
Examples
The following example shows how to use the DashStyle property of a Pen to create a dashed line under text.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<StackPanel Margin="20">
<TextBlock FontSize="36">
the lazy brown dog.
<TextBlock.TextDecorations>
<TextDecoration Location="Underline"
PenThicknessUnit="FontRecommended">
<TextDecoration.Pen>
<Pen Thickness="1.5" Brush="Red" >
<!-- For the underline, create a dashed line with each
dash twice the thickness of the Pen and each gap 8 times
the thickness of the Pen. -->
<Pen.DashStyle>
<DashStyle Dashes="2,8"/>
</Pen.DashStyle>
</Pen>
</TextDecoration.Pen>
</TextDecoration>
</TextBlock.TextDecorations>
</TextBlock>
</StackPanel>
</Page>
Remarks
This collection describes the length of alternating dashes and gaps. The values in the collection are in terms of multiples of the Thickness of the Pen. For example, an array of 1
,2
specifies a dash of length (1
* Thickness) followed by a gap of length (2
* Thickness).
Note
The actual length of the dash that is drawn depends on the style of DashCap that is added to each end of the dash. The default DashCap value for a Pen is Square. This causes an end cap that is one half the thickness of the line to be added onto each end of the pen stroke. (See PenLineCap for an example.) Therefore, if you specify an array of 0
, 2
and a square DashCap, the actual dash length will be (0
* Thickness) + (2
* DashCap).
If there are an odd number of values in the collection, the values are interpreted as if they had been repeated once to produce an even number of values. For example, a collection containing 2
,3
,5
is interpreted the same as a collection containing 2
,3
,5
,2
,3
,5
.
Negative values in the array are interpreted as their absolute value.
Dependency Property Information
Identifier field | DashesProperty |
Metadata properties set to true |
None |