带有换行和大量数据的 TextBox 性能不佳 [英] Poor TextBox performance with wrapping on and large amounts of data

查看:31
本文介绍了带有换行和大量数据的 TextBox 性能不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 .NET 3.5 的 WPF 中的文本框一直存在问题.在启用了换行的 TextBox 中有大量(5000 多行)数据时,窗口在调整大小时的性能非常糟糕.

I have a persistent problem with textboxes in WPF, using .NET 3.5. With a large (5000+ lines) amount of data in a TextBox with wrapping enabled, the window has ridiculously bad performance while being resized.

发生在 TextWrapping="Wrap" 中.绑定文本数据或仅以编程方式设置它没有区别.

This only happens with TextWrapping="Wrap". Having the text data bound or just setting it programmatically makes no difference.

代码就这么简单:

<TextBox Margin="12,39,337,29" Text="{Binding Output, Mode=OneWay}" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" />

文本绑定到单个字符串.绑定数据未更改.

The text is bound to a single string. The bound data is not being changed.

在调整窗口大小时数据没有被更改,这就是我的意思.它会在未来更新.TextBox 不需要是可编辑的,但实际文本确实需要是可选择的./编辑.

The data is not being changed while the window is resizing, is what I meant. It will be updated in the future. The TextBox does not need to be editable, but the actual text does need to be selectable. /Edit.

我已经快速使用了 AvalonEdit,它也有同样的问题.我找不到任何其他描述此问题的线程,这似乎很奇怪.

I've had a quick play with AvalonEdit, which has the same problem. It seems strange that I can't find any other threads which describe this issue.

有什么建议吗?

谢谢,丰富

推荐答案

您可以对 windowResizeStart 事件做出反应并禁用文本块的换行.然后在调整大小完成时包装一次.

You could react to the windowResizeStart event and disable wrapping for the text block. Then wrap just once when the resize completes.

我猜你获得了性能,但失去了一些视觉天赋.

You gain performance but lose some visual flair I guess.

这篇关于带有换行和大量数据的 TextBox 性能不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆