This documentation is archived and is not being maintained.

FlowDocumentReader.Document Property

Gets or sets a FlowDocument that hosts the content to be displayed by the FlowDocumentReader. This is a dependency property.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public FlowDocument Document { get; set; }
<object>
  <FlowDocument .../>
</object>

Property Value

Type: System.Windows.Documents.FlowDocument
A FlowDocument that hosts the content to be displayed by the FlowDocumentReader. The default is null.

Identifier field

DocumentProperty

Metadata properties set to true

None

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

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

<FlowDocumentReader
  Name="flowDocRdr" 
  IsFindEnabled="True"  
  IsPrintEnabled="True"
  MinZoom="50" MaxZoom="1000"
  Zoom="120" ZoomIncrement="5"
/>

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

  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 FlowDocumentReader.

The following example performs these steps.

void LoadFlowDocumentReaderWithXAMLFile(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.
    flowDocRdr.Document = content;

    xamlFile.Close();
}

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.

For a functional sample that enables the user to load a XAML file into a FlowDocumentReader, see FlowDocumentReader Load/Save XAML Sample.

More Code

How to: Save the Contents of a FlowDocumentReader as a XAML File This example demonstrates how to save the contents of a FlowDocumentReader (represented by the Document property) as a XAML file.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Show: