RichTextBox.Document Property

Gets or sets the FlowDocument that represents the contents of the RichTextBox.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:

public FlowDocument Document { get; set; }
/** @property */
public FlowDocument get_Document ()

/** @property */
public void set_Document (FlowDocument value)

public function get Document () : FlowDocument

public function set Document (value : FlowDocument)

  <FlowDocument .../>

Property Value

A FlowDocument object that represents the contents of the RichTextBox. By default, this property is set to an empty FlowDocument. Specifically, the empty FlowDocument contains a single Paragraph, which contains a single Run which contains no text.

Exception typeCondition


Raised if an attempt is made to set this property to null.


Raised if an attempt is made to set this property to a FlowDocument that represents the contents of another RichTextBox.


Raised if this property is set while a change block has been activated.

A FlowDocument may only be hosted by a single RichTextBox. Specifying a single FlowDocument as the contents of multiple RichTextBox controls is not supported.

The following example illustrates the use of this property.

// 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;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0