0

我正在动态创建 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);
4

1 回答 1

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;
}
于 2014-05-13T18:28:26.113 回答