방법: 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 샘플을 참조하십시오.