How can I load an XAML file into a FlowDocumentReader?

Platform: WPF| Category: Flow Content

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

[XAML]

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

And write the following FlowDocument to the file stream :

[C#]

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();
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.