Dela via


RichTextBlock.TextDecorations Property

Definition

Gets or sets a value that indicates what decorations are applied to the text.

public:
 property TextDecorations TextDecorations { TextDecorations get(); void set(TextDecorations value); };
TextDecorations TextDecorations();

void TextDecorations(TextDecorations value);
public TextDecorations TextDecorations { get; set; }
var textDecorations = richTextBlock.textDecorations;
richTextBlock.textDecorations = textDecorations;
Public Property TextDecorations As TextDecorations
<RichTextBlock TextDecorations="textDecorationsMemberName"/>

Property Value

A value of the enumeration. The default is None.

Windows requirements

Device family
Windows 10 Creators Update (introduced in 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v4.0)

Examples

This example shows how to apply text decorations to text in a RichTextBlock, both at the control level and at the TextElement level.

<RichTextBlock TextDecorations="Underline"
            Loaded="RichTextBlock_Loaded">
    <Paragraph>This text has an underline.</Paragraph>
    <Paragraph TextDecorations="Strikethrough">
        This text has a strikethrough, but no underline.
    </Paragraph>
    <Paragraph TextDecorations="Strikethrough, Underline">This text has it all!</Paragraph>
    <Paragraph x:Name="Paragraph4">This text is decorated in code.</Paragraph>
</RichTextBlock>
private void RichTextBlock_Loaded(object sender, RoutedEventArgs e)
{
    // Apply both strikethough and underline to the last paragraph.
    Paragraph4.TextDecorations =
        TextDecorations.Strikethrough | TextDecorations.Underline;
}

Remarks

Starting with the Windows 10 Creators Update (SDK version 15063), this property is the preferred way to strikethrough or underline text.

For earlier versions of Windows, you can underline text with the Underline class.

Applies to

See also