次の方法で共有


方法 : FlowDocumentPageViewer のコンテンツを XAML ファイルとして保存する

更新 : 2007 年 11 月

この例では、Document プロパティで表されている FlowDocumentPageViewer のコンテンツを XAML ファイルとして保存する方法を示します。

使用例

次の例では、下のコード例によって操作される FlowDocumentPageViewer という名前の空の要素を定義します。

<FlowDocumentPageViewer
  Name="flowDocPageViewer" 
  MinZoom="50" MaxZoom="1000"
  Zoom="120" ZoomIncrement="5"
  />

FlowDocumentPageViewer のコンテンツをファイルに保存するには、ファイル ストリームを開くか、または作成し、XamlWriter クラスによって提供される Save メソッドを使用して FlowDocument をファイル ストリームに書き込みます。

これらの手順を次の例で実行します。

void SaveFlowDocumentPageViewerWithXAMLFile(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(flowDocPageViewer.Document, xamlFile);

    xamlFile.Close();
}

参照

処理手順

方法 : XAML ファイルを FlowDocumentPageViewer に読み込む