25MB を超える巨大なドキュメントを FlowDocument にロードしています。すべて問題ありませんが、初期化中にデータ全体を FlowDocument にロードするのに、より多くの CPU または長い時間がかかります。その代わりに、FlowDocument コントロールの下部にある次のページのクリックに基づいてページを動的にロードする方法があります。
フロー ドキュメントのサンプル コード。
<ScrollViewer HorizontalAlignment="Stretch">
<GroupBox>
<GroupBox.Header>
<TextBlock Text="Standard Output"></TextBlock>
</GroupBox.Header>
<FlowDocument Name="flowDocument" ColumnWidth="999999" Background="Transparent" IsColumnWidthFlexible="True" >
<Paragraph Name="para" Background="Transparent" TextAlignment="Justify" KeepTogether="True">
</Paragraph>
</FlowDocument>
</GroupBox>
</ScrollViewer>
コードビハインドファイルにデータを割り当てています。
コード ビハインド ファイルにフロードキュメントを設定するコード。
para.Inlines.Add(ReadDocument());
public void ReadDocument()
{
textToDisplay = File.ReadAllText(@"C:\sampleLog.txt");
}