我需要在 WPF 代码中展示大量文本数据。起初,我尝试使用 TextBox(当然,渲染速度太慢了)。现在我正在使用 FlowDocument,它很棒,但最近又有一个要求:文本不应该被连字号分隔。据说这是不可能的(document.IsHyphenationEnabled = false
),但我仍然看不到我的宝贵水平滚动条。如果我放大文本比例,就会出现连字号。
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" />
没有犯罪行为 =))
我想知道如何驯服这个野兽 - 搜索没有什么有用的信息。或者您有其他的方法来显示大量文本,或者文本框有一些虚拟化功能,我只需要启用即可。无论如何,我很高兴听到您的回复!