“虚拟”中的 WPF 文本框模式

发布于 2024-08-22 18:10:30 字数 56 浏览 3 评论 0原文

是否可以在“虚拟”模式下使用 TextBox。

我想在用户滚动文档时按需提供文本。

Is it possible to use TextBox in "virtual" mode.

I want to supply text on demand, when user scrolls through the document.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绝不放开 2024-08-29 18:10:30

要使用内置虚拟化(即默认 ListBox 使用的 VirtualizingStackPanel),您需要能够将内容分块为可以根据需要一次逐步加载一个的项目(逻辑滚动)。要对任意大文本执行此操作,需要进行大量预处理来计算换行并将文本分解为行或行组。一旦执行此操作,您将需要使用从 ItemsControl 派生的容器,而不是单个 TextBox。您是否需要可编辑的文本?

To use the built in virtualization (i.e. VirtualizingStackPanel used by default ListBox) you need to be able to chunk the content into items which can be progressively loaded one at a time as needed (logical scrolling). To do this for arbitrary large text would involve a lot of pre-processing to calculate line wrapping and break the text up into lines or groups of lines. Once you do that you would need to use a container derived from ItemsControl instead of a single TextBox. Do you have a requirement to have editable text?

旧人九事 2024-08-29 18:10:30

我认为虚拟模式旨在通过仅按需获取和渲染数据来提高应用程序性能。如果用户滚动浏览文档,这是否意味着数据已经加载?您不能将 TextBox 数据绑定到代码隐藏中的属性,并仅在用户滚动时设置该属性的值吗?

I thought virtual mode was intended to speed up application performance by only getting and rendering data on demand. If the user is scrolling through the document, doesn't that imply that the data is already loaded? Couldn't you databind the TextBox to a property in code-behind and merely set the value of that property while the user is scrolling?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文