TextBlock.TextDecorations 屬性

定義

取得或設定值,這個值表示套用至文字的裝飾。

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

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

屬性值

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

範例

此範例示範如何將裝飾套用至文字。

<!-- Apply underline. -->
<TextBlock Text="Sample text" TextDecorations="Underline"/>

<!-- Apply underline and strikethrough. -->
<TextBlock Text="Sample text" TextDecorations="Underline, Strikethrough"/>

<!-- Apply decorations in code. -->
<TextBlock x:Name="TextBlock3" Text="Sample Text"
           Loaded="TextBlock_Loaded" />
private void TextBlock_Loaded(object sender, RoutedEventArgs e)
{
    // Apply both strikethough and underline to TextBlock3.
    TextBlock3.TextDecorations =
        TextDecorations.Strikethrough | TextDecorations.Underline;
}

備註

從 Windows 10 Creators Update (SDK 15063 版) 開始,此屬性是刪除線或底線文字的慣用方式。

對於舊版的 Windows,您可以使用 Underline 類別加上文字底

適用於