語言

TextBlock.TextDecorations 屬性

定義

取得或設定 a TextDecorationCollection ,包含可應用於 文本 TextBlock的效果。

public:
 property System::Windows::TextDecorationCollection ^ TextDecorations { System::Windows::TextDecorationCollection ^ get(); void set(System::Windows::TextDecorationCollection ^ value); };
public System.Windows.TextDecorationCollection TextDecorations { get; set; }
member this.TextDecorations : System.Windows.TextDecorationCollection with get, set
Public Property TextDecorations As TextDecorationCollection

屬性值

一個 TextDecorationCollection 包含可用於此元素的文字裝飾的收藏。 預設是 null (未施加文字裝飾)。

範例

以下範例說明如何設定屬性 TextDecorations 。

<TextBlock TextDecorations="Strikethrough">
  This text will render with the strikethrough effect.
</TextBlock>

下圖顯示此範例的轉譯方式。

截圖:文字帶有預設劃線效果

以下圖表分別展示了 、 OverLine和 Baseline 裝飾的渲染方式Underline。

截圖:Overline TextDecorator

截圖:文字預設基線效果

截圖:帶有預設底線效果

下列示範如何以程式設計的方式設定 Typography 屬性。

TextBlock textBlock = new TextBlock(new Run("This text will render with the strikethrough effect."));
textBlock.TextDecorations = TextDecorations.Strikethrough;
Dim textBlock As New TextBlock(New Run("This text will render with the strikethrough effect."))
textBlock.TextDecorations = TextDecorations.Strikethrough

備註

物件 TextDecoration 是你可以加在文字上的視覺裝飾。 文字裝飾有四種類型:底線、底線、劃線和上線。 欲了解更多關於文字裝飾的資訊,請參閱 「如何製作文字裝飾」。

預設情況下,這個屬性會被設定為 , null 且沒有 TextDecorationCollection 相關關聯。 在新增任何文字特效前,先建立一個新的 TextDecorationCollection 並指派到這個屬性。

相依財產資訊

Item 價值觀
識別碼欄位 TextDecorationsProperty
元資料屬性設為 true AffectsRender

適用於