RichTextBox.Document 属性

定义

获取或设置表示 FlowDocument 的内容的 RichTextBox

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

属性值

FlowDocument

一个 FlowDocument 对象,表示 RichTextBox 的内容。

默认情况下,此属性设置为空 FlowDocument。 具体地说,此空 FlowDocument 包含一个 Paragraph,而后者包含一个不包括任何文本的 Run

例外

尝试将该属性设置为 null

尝试将此属性设置为表示其他 FlowDocument 的内容的 RichTextBox

在激活 change 块时设置此属性。

示例

以下示例演示了此属性的使用。

// Create a simple FlowDocument to serve as content.
FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("Simple FlowDocument")));
// Create an empty, default RichTextBox.
RichTextBox rtb = new RichTextBox();
// This call sets the contents of the RichTextBox to the specified FlowDocument.
rtb.Document = flowDoc;
// This call gets a FlowDocument representing the contents of the RichTextBox.
FlowDocument rtbContents = rtb.Document;
' Create a simple FlowDocument to serve as content.
Dim flowDoc As New FlowDocument(New Paragraph(New Run("Simple FlowDocument")))
' Create an empty, default RichTextBox.
Dim rtb As New RichTextBox()
' This call sets the contents of the RichTextBox to the specified FlowDocument.
rtb.Document = flowDoc
' This call gets a FlowDocument representing the contents of the RichTextBox.
Dim rtbContents As FlowDocument = rtb.Document

注解

FlowDocument 只能由单个 RichTextBox托管。 不支持将单个 FlowDocument 指定为多个 RichTextBox 控件的内容。

适用于