TextDecoration::Pen Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

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

property Pen^ Pen {
	Pen^ get();
	void set(Pen^ value);

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.

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

Text decoration with linear gradient underline

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

Identifier field


Metadata properties set to true


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.
          <Pen Thickness="1.5">
              <LinearGradientBrush Opacity="0.5"
                StartPoint="0,0.5"  EndPoint="1,0.5">
                  <GradientStop Color="Yellow" Offset="0" />
                  <GradientStop Color="Red" Offset="1" />
              <DashStyle Dashes="2"/>

.NET Framework
Available since 3.0
Return to top