Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在WPF中显示大文本的最佳方式?_Wpf_Controls_Textview - Fatal编程技术网

在WPF中显示大文本的最佳方式?

在WPF中显示大文本的最佳方式?,wpf,controls,textview,Wpf,Controls,Textview,我需要在WPF代码中显示大量的文本数据。首先我尝试使用(当然渲染速度太慢)。现在我正在使用——而且它很棒——但最近我有另一个要求:文本不应该连字符。应该不是(document.IsHyphenationEnabled=false),但我仍然看不到宝贵的水平滚动条。如果我放大比例文本是。。。连字符 这就是我创建FlowDocument的方式——下面是我的WPF控件的一部分: <FlowDocumentReader Name="flowReader" Margin="2 2 2 2" Gri

我需要在WPF代码中显示大量的文本数据。首先我尝试使用(当然渲染速度太慢)。现在我正在使用——而且它很棒——但最近我有另一个要求:文本不应该连字符。应该不是(
document.IsHyphenationEnabled=false
),但我仍然看不到宝贵的水平滚动条。如果我放大比例文本是。。。连字符

这就是我创建FlowDocument的方式——下面是我的WPF控件的一部分:

<FlowDocumentReader Name="flowReader" Margin="2 2 2 2" Grid.Row="0" />

没什么犯罪的


我想知道如何驯服这只野兽-谷歌搜索没有任何帮助。或者你有其他方式来显示兆字节的文本,或者textbox有一些虚拟化功能,我只需要启用这些功能。不管怎样,我很高兴听到你的回答

它实际上是包装而不是连字符。可以通过将FlowDocument.PageWidth设置为合理的值来克服这个问题,唯一的问题是如何确定这个值。 Omer建议了这个配方,但我不喜欢使用TextBlock作为文本的测量工具。更好的方法:

            Paragraph paragraph = new Paragraph();
            paragraph.Inlines.Add(value);


            FormattedText text = new FormattedText(value, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(paragraph.FontFamily, paragraph.FontStyle, paragraph.FontWeight, paragraph.FontStretch), paragraph.FontSize, Brushes.Black );

            FlowDocument document = new FlowDocument(paragraph);
            document.PageWidth = text.Width*1.5;
            document.IsHyphenationEnabled = false;

Omer-感谢您的指导。

您的问题不是断字。它是环绕的。看看这里:,他们建议将段落的宽度设置为大于视图窗口的宽度。感谢Omer-链接和建议似乎非常明智。将很快尝试:)请在此处查看答案:
            Paragraph paragraph = new Paragraph();
            paragraph.Inlines.Add(value);


            FormattedText text = new FormattedText(value, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(paragraph.FontFamily, paragraph.FontStyle, paragraph.FontWeight, paragraph.FontStretch), paragraph.FontSize, Brushes.Black );

            FlowDocument document = new FlowDocument(paragraph);
            document.PageWidth = text.Width*1.5;
            document.IsHyphenationEnabled = false;