RichTextBlock.TextDecorations 属性

定义

获取或设置一个值,该值指示应用于文本的修饰。

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"/>

属性值

枚举的一个值。 默认值为“无”。

示例

此示例演示如何在控件级别和 TextElement 级别对 RichTextBlock 中的文本应用文本修饰。

<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;
}

注解

从 Windows 10 创意者更新 (SDK 版本 15063) 开始,此属性是删除线或下划线文本的首选方法。

对于早期版本的 Windows,可以使用 “下划线”类为文本添加下划线

适用于

另请参阅