This documentation is archived and is not being maintained.

Pen.DashStyle Property

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

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

public DashStyle DashStyle { get; set; }
    <DashStyle .../>

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.

Identifier field


Metadata properties set to true


The DashStyles class provides a set of predefined dash patterns.

The following example shows how to use the DashStyle property of a Pen to create a dashed line under text.

<Page xmlns="" 
  xmlns:x="" >
  <StackPanel Margin="20">

    <TextBlock FontSize="36">
      the lazy brown dog.
        <TextDecoration Location="Underline"  
            <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. -->
                <DashStyle Dashes="2,8"/>

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0