TextDecorationLocation Enumeration


Specifies the vertical position of a TextDecoration object.

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

Public Enumeration TextDecorationLocation

Member nameDescription

The vertical position of a baseline.


The vertical position of an overline.


The vertical position of a strikethrough.


The vertical position of an underline. This is the default value.

Text decorations are available in four types: baseline, overline, strikethrough, and underline. The following example shows the locations of the text decorations relative to the text.

Diagram of text decoration locations

Text decoration types

The following example creates an underline text decoration and uses a solid color brush for the pen.

' Use a Red pen for the underline text decoration.
Private Sub SetRedUnderline()
	' Create an underline text decoration. Default is underline.
	Dim myUnderline As New TextDecoration()

	' Create a solid color brush pen for the text decoration.
	myUnderline.Pen = New Pen(Brushes.Red, 1)
	myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended

	' Set the underline decoration to a TextDecorationCollection and add it to the text block.
	Dim myCollection As New TextDecorationCollection()
	TextBlock2.TextDecorations = myCollection
End Sub
<!-- Use a Red pen for the underline text decoration -->
  FontSize="36" >
  jumped over
          <Pen Brush="Red" Thickness="1" />

.NET Framework
Available since 3.0
Return to top