Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Pen.DashStyle Property

 

Gets or sets a value that describes the pattern of dashes generated by this Pen.

Namespace:   System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

public DashStyle DashStyle { get; set; }

Property Value

Type: System.Windows.Media.DashStyle

A value that describes the pattern of dashes generated by this Pen. The default is DashStyles.Solid, which indicates that there should be no dashes.

The DashStyles class provides a set of predefined dash patterns.

Identifier field

DashStyleProperty

Metadata properties set to true

None

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>

.NET Framework
Available since 3.0
Return to top
Show:
© 2017 Microsoft