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.
Example
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"
/>
To save the contents of the FlowDocumentReader to a file, open or create the file stream and use the Save method provided by the XamlWriter class to write the FlowDocument to the file stream.
The following example performs these steps.
void SaveFlowDocumentReaderWithXAMLFile(string fileName)
{
// Open or create the output file.
FileStream xamlFile = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite);
// Save the contents of the FlowDocumentReader to the file stream that was just opened.
XamlWriter.Save(flowDocRdr.Document, xamlFile);
xamlFile.Close();
}
For a functional sample that enables the user to save the contents of a FlowDocumentReader as a XAML file, see FlowDocumentReader Load/Save XAML Sample.