This documentation is archived and is not being maintained.

FlowDocumentScrollViewer.Document Property

Gets or sets a FlowDocument that hosts the content to be displayed by the FlowDocumentScrollViewer.

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 that hosts the content to be displayed by the FlowDocumentScrollViewer. The default property is null.

This example demonstrates how to parse a XAML file that contains a FlowDocument, and display the loaded file in a FlowDocumentScrollViewer.

The following example defines an empty, named FlowDocumentScrollViewer that will be manipulated by the code example below.

  MinZoom="50" MaxZoom="1000"
  Zoom="120" ZoomIncrement="5"

At the most basic level, there are steps involved in loading a FlowDocument file into a FlowDocumentScrollViewer.

  1. Open the FlowDocument file as a stream.

  2. Parse the stream into a FlowDocument object. The Load method provided by the XamlReader class is intended to perform this operation.

  3. Set the resulting FlowDocument object as the value of the Document property on the FlowDocumentScrollViewer.

The following example performs these steps.

void LoadFlowDocumentScrollViewerWithXAMLFile(string fileName)
    // Open the file that contains the FlowDocument...
    FileStream xamlFile = new FileStream(fileName, FileMode.Open, FileAccess.Read);
    // and parse the file with the XamlReader.Load method.
    FlowDocument content = XamlReader.Load(xamlFile) as FlowDocument;
    // Finally, set the Document property to the FlowDocument object that was
    // parsed from the input file.
    flowDocScrollViewer.Document = content;


If the FlowDocument references external resources (such as image files) using relative uniform resource identifiers (URIs), it is necessary to specify a ParserContext that includes a BaseUri so that the parser can make sense of the relative URIs. The XamlReader class provides Load method that accepts a ParserContext.

More Code

How to: Save the Contents of a FlowDocumentScrollViewer as a XAML File

This example demonstrates how to save the contents of a FlowDocumentScrollViewer (represented by the Document property) as a XAML file.

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