共用方式為


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

屬性值

列舉值。 預設值為 [無]。

範例

此範例示範如何將文字裝飾套用至 RichTextBlock 中的文字,同時在控件層級和 TextElement 層級。

<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 Creators Update (SDK 15063 版) 開始,此屬性是刪除線或底線文字的慣用方式。

針對舊版 Windows,您可以使用 Underline 類別來加上文字 底線

適用於

另請參閱