TextDecoration::Pen Property

Gets or sets the Pen used to draw the text decoration.

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public:
property Pen^ Pen {
	Pen^ get ();
	void set (Pen^ value);
}
<object>
  <object.Pen>
    <Pen .../>
  </object.Pen>
</object>

Property Value

Type: System.Windows.Media::Pen
The Pen used to draw the text decoration. If this value is null, the decoration color matches the text to which it is applied and the decoration's thickness is set to the font's recommended thickness.

Identifier field

PenProperty

Metadata properties set to true

None

The following example shows a text decoration that has been styled with a linear gradient brush and a dashed pen.

Example of an underline styled with a linear gradient brush and dashed pen

Text decoration with linear gradient underline

In the following code example, an underline text decoration is created with a linear gradient brush for the dashed pen.

No code example is currently available or this language may not be supported.

<!-- Use a linear gradient pen for the underline text decoration. -->
<TextBlock FontSize="36">the lazy brown dog.
  <TextBlock.TextDecorations>
    <TextDecorationCollection>
      <TextDecoration  
        PenThicknessUnit="FontRecommended">
        <TextDecoration.Pen>
          <Pen Thickness="1.5">
            <Pen.Brush>
              <LinearGradientBrush Opacity="0.5"
                StartPoint="0,0.5"  EndPoint="1,0.5">
                <LinearGradientBrush.GradientStops>
                  <GradientStop Color="Yellow" Offset="0" />
                  <GradientStop Color="Red" Offset="1" />
                </LinearGradientBrush.GradientStops>
              </LinearGradientBrush>
            </Pen.Brush>
            <Pen.DashStyle>
              <DashStyle Dashes="2"/>
            </Pen.DashStyle>
          </Pen>
        </TextDecoration.Pen>
      </TextDecoration>
    </TextDecorationCollection>
  </TextBlock.TextDecorations>
</TextBlock>


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft