在WinRT中绑定到ItemsControl的ObservableCollection中的虚拟化/分页数据 [英] Virtualizing/Paging Data in ObservableCollection bound to ItemsControl in WinRT

查看:76
本文介绍了在WinRT中绑定到ItemsControl的ObservableCollection中的虚拟化/分页数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何可视化设置为ItemsControl的ItemSource的ObservableCollection或List中的数据? 由于某些技术原因(设计约束),我们在ScrollViewer中使用ItemsControl来创建自定义集合控件,我们不能使用ListView或GridView控件,后者通过ISupportIncremental支持VirtualizingStackPanel和Data Virtualization,因此我们必须在ScrollViewer中使用ItemsControl . 因此,我们的ScrollViewer控件如何通知绑定的Observable集合滚动已结束并将更多数据加载到ObservableCollection中, 我发现了有关随机访问数据虚拟化的一些信息,但不确定如何在WinRT,C#Custom Control项目和示例代码中实现这些信息

How can we Visualize data in an ObservableCollection or List which is set as ItemSource of ItemsControl? We are using ItemsControl within a ScrollViewer to make a custom collections control, due to some technical reasons(Design Constraints), we can not use ListView, or GridView controls which supports VirtualizingStackPanel and Data Virtualization through ISupportIncremental, so we must use ItemsControl within a ScrollViewer. So how can our ScrollViewer control notify the bound observable collection that scrolling has come to an end and load more data into the ObservableCollection, I found some information on Random access data virtualization but not sure how would i implement that in my WinRT, C# Custom Control project, and sample codes would be helpful

推荐答案

如果您要实现自定义列表控件(如果您未使用ListViewGridViewListBox,则为自定义列表控件),则ScrollViewer需要成为其模板的一部分,因此您可以收听具有

If you're implementing a custom list control (which you are if you're not using ListView, GridView or ListBox) then the ScrollViewer would need to be a part of its template, so you can listen to its ViewChanging and ViewChanged events that have IsInertial and IsIndeterminate properties which you could use to see if scrolling has stopped and you could possibly use these to decide whether you have time to get more data or just put some placeholder values in the items source. You would also likely have an items source property and since you want to do your own virtualization - you don't really need to care about ISupportIncremental although you could use it as a (hopefully) good example. You get to implement your own virtualizing panel and the source list. Your view change events from the ScrollViewer and the layout of your panel would drive what gets loaded from the items source.

至于示例代码-我还没看过,但也希望能看到一些!

As for sample code - I haven't seen any, but would love to see some as well!

这篇关于在WinRT中绑定到ItemsControl的ObservableCollection中的虚拟化/分页数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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