次の方法で共有


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

更新 : 2007 年 11 月

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

使用例

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

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

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

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

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

ユーザーが FlowDocumentReader のコンテンツを XAML ファイルとして保存できるようにする機能のサンプルについては、「FlowDocumentReader の読み込み/保存 XAML のサンプル」を参照してください。

参照

処理手順

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