我正在动态创建FlowDocumentScrollViewer如何在FlowDocumentScrollViewer中打开.txt文件? 我使用richtextbox时使用了这个,但是如何在FlowDocumentScrollViewer中执行相同操作?
fStream = new FileStream(filePath, FileMode.OpenOrCreate);
range = new TextRange(mcRTB.Document.ContentStart, mcRTB.Document.ContentEnd);
range.Load(fStream, DataFormats.Text);
答案 0 :(得分:0)
知道了:
FlowDocumentScrollViewer flowDocumentSV = new FlowDocumentScrollViewer();
try
{
fStream = new FileStream(filePath, FileMode.OpenOrCreate);
FlowDocument flowDocument = new FlowDocument();
range = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);
range.Load(fStream, DataFormats.Text);
flowDocScrollViewer.Document = flowDocument;
}