HOW TO:將 FlowDocumentPageViewer 的內容儲存為 XAML 檔
更新:2007 年 11 月
本範例示範如何將 FlowDocumentPageViewer 的內容 (以 Document 屬性表示) 儲存為 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();
}