“虚拟”中的 WPF 文本框模式
是否可以在“虚拟”模式下使用 TextBox。
我想在用户滚动文档时按需提供文本。
Is it possible to use TextBox in "virtual" mode.
I want to supply text on demand, when user scrolls through the document.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要使用内置虚拟化(即默认 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?
我认为虚拟模式旨在通过仅按需获取和渲染数据来提高应用程序性能。如果用户滚动浏览文档,这是否意味着数据已经加载?您不能将 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?