2
我需要在WPF代码中显示非常大量的文本数据。首先,我尝试使用TextBox(当然,渲染速度太慢)。现在我正在使用FlowDocument - 它真棒 - 但最近我有另一个要求:文本不应该连字符。据说它不是(document.IsHyphenationEnabled = false
),但我仍然看不到我珍贵的水平滚动条。如果我放大比例文本是...连字符。在WPF中显示大文本的最佳方式?
public string TextToShow
{
set
{
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add(value);
FlowDocument document = new FlowDocument(paragraph);
document.IsHyphenationEnabled = false;
flowReader.Document = document;
flowReader.IsScrollViewEnabled = true;
flowReader.ViewingMode = FlowDocumentReaderViewingMode.Scroll;
flowReader.IsPrintEnabled = true;
flowReader.IsPageViewEnabled = false;
flowReader.IsTwoPageViewEnabled = false;
}
}
这就是我创建的FlowDocument - 而这才是我的WPF控件的一部分:
<FlowDocumentReader Name="flowReader" Margin="2 2 2 2" Grid.Row="0" />
没有犯罪=))
我想知道如何驯服这只野兽 - 谷歌搜索没有任何帮助。或者你有其他的方式来显示兆字节的文本,或者文本框有一些我需要启用的虚拟化功能。无论如何,我很乐意听到你的回应!
你的问题不是连字符。它环绕着。看看这里:http://msdn.itags.org/visual-studio/36912/,他们建议设置大于视图窗口的段落宽度。 – OmerGertel 2010-09-06 17:34:19
谢谢奥默尔 - 链接和建议似乎相当明智。将尽快尝试:) – ProfyTroll 2010-09-06 21:00:29
在此处查看答案:https://stackoverflow.com/questions/807347/how-do-i-handle-edit-large-amount-of-text-in-wpf/46546877#46546877 – juFo 2017-10-03 14:21:51