LongListSelector 数据虚拟化 [英] LongListSelector Data Virtualization

查看:20
本文介绍了LongListSelector 数据虚拟化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LongListSelector 是否支持数据虚拟化?我在几个博客上读到它确实如此,但无法让它工作.

Does LongListSelector support Data Virtualization? I read on several Blogs that it does, but can't get it to work.

这是我尝试过的:我向列表提供了一个 IList 实现作为 ItemsSource.问题是 List 调用 GetEnumerator() 而不是 this[int index] 来获取列表项.

Here is what I tried: I provided a IList implementation as ItemsSource to the List. The problem is that the List calls GetEnumerator() instead of this[int index] to get a list item.

所以我的问题是:如何为 LongListSelector 实现数据虚拟化?

So my question: How do I implement data virtualization for LongListSelector?

推荐答案

如您所说,LongListSelector 仍然基于 GetEnumerator,即使在呈现 IList 类型时也是如此.很可能需要重写控件以支持该目的.虽然博客可能会说它支持它,但没有人说如何,所以我不倾向于相信他们.LongListSelector 的默认值是呈现所有项目.

As you said, the LongListSelector is still based around GetEnumerator even for when rendering IList types. Most likely the control would need to be rewritten to support the purpose. While blogs might say it support it, none of them says how, so I'm not inclined to believe them. The LongListSelector's default is to render all items.

至于数据的加载,可以使用 ObservableCollection 逐步完成.我有一个 示例项目,它展示了如何将 ObservableCollection 与 LongListSelector 结合使用.

As for the loading of the data, it can be done progressive using a ObservableCollection. I got a example project that shows how to use a ObservableCollection in combination with the LongListSelector.

基本上,这可以让您逐步添加更多组和/或向组中添加更多数据,并且 UI 应相应更新.

Basically this could allow you to progressively add more groups and/or, more data to the groups, and the UI should update accordingly.

这篇关于LongListSelector 数据虚拟化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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