2008-11-18 61 views

回答

1

這裏有一種將代碼保存爲原始xaml(文本文件)的方法,假設flowdocument(非查看器)本身被命名爲「myFlowDoc」,如果僅查看器被命名,則使用該屬性。查看器的文檔來獲取它。而流myStream(FileStream,MemoryStream等沒有關係)的流。

// Create a TextRange around the entire document. 
TextRange documentTextRange = new TextRange(myFlowDoc.ContentStart, myFlowDoc.ContentEnd); 

// Save it. Note that it will not respect current stream position; 
// it'll assume that it gets the entire stream. 
documentTextRange.Save(myStream, DataFormats.Xaml);