共用方式為


TextBlock.Text 屬性

定義

取得或設定 的文字內容 TextBlock

public:
 property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
[System.Windows.Localizability(System.Windows.LocalizationCategory.Text)]
public string Text { get; set; }
[<System.Windows.Localizability(System.Windows.LocalizationCategory.Text)>]
member this.Text : string with get, set
Public Property Text As String

屬性值

本文 TextBlock內容。 請注意,所有非文字內容都被剔除,內容呈現純文字 TextBlock 呈現。 預設值為 Empty

屬性

範例

以下範例說明如何設定 Text 元素 TextBlock 的屬性。

<TextBlock Text="The text contents of this TextBlock element."/>

或者,文字執行的內容也可以直接以 TextBlock 元素標籤來包含。

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

TextBlock textBlock = new TextBlock();
textBlock.Text = "The text contents of this TextBlock.";
Dim textBlock As New TextBlock()
textBlock.Text = "The text contents of this TextBlock."

備註

當你想在 TextBlock. 當你需要格式化文字時,就把物件加入 Inline 屬性裡 Inlines

相依財產資訊

項目 價值
識別碼欄位 TextProperty
元資料屬性設為 true AffectsMeasureAffectsRender

適用於