Run.Text 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定此文字 Run中未格式化的文字內容。
public:
property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public string Text { get; set; }
member this.Text : string with get, set
Public Property Text As String
屬性值
一個字串,用來指定該文字 Run的未格式化內容。 預設值為 Empty。
範例
以下範例展示了如何直接設定 Text 元素屬性 Run ,並使用綁定。
<StackPanel>
<StackPanel.Resources>
<TextBox x:Key="DataStore" Text="This is an example of text flow using bound run" />
</StackPanel.Resources>
<FlowDocumentReader>
<FlowDocument>
<Paragraph>
<Run Text="This is an example of Run" />
</Paragraph>
<Paragraph>
<Run Text="{Binding Source={StaticResource DataStore}, Path=Text}" />
</Paragraph>
</FlowDocument>
</FlowDocumentReader>
</StackPanel>
備註
從 .NET Framework 4 開始, Text 物件的 Run 屬性是相依屬性,這表示你可以將該 Text 屬性綁定到資料來源。 此 Text 特性完全支援單向綁定 FlowDocumentReader 及其他顯示唯讀文字的控制項。 欲了解更多資料綁定資訊,請參閱 資料綁定概覽。
備註
不支援將文字綁定到 Run 其中 RichTextBox 的物件。 在 內 RichTextBox 進行編輯操作可能會導致綁定被清除。