TextDecoration::Pen Property

 
System_CAPS_noteNote

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)

public:
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

PenProperty

Metadata properties set to true

None

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
Available since 3.0
Return to top
Show: