在WinRT中绑定到ItemsControl的ObservableCollection中的虚拟化/分页数据 [英] Virtualizing/Paging Data in ObservableCollection bound to ItemsControl in WinRT
问题描述
我们如何可视化设置为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
推荐答案
如果您要实现自定义列表控件(如果您未使用ListView
,GridView
或ListBox
,则为自定义列表控件),则ScrollViewer
需要成为其模板的一部分,因此您可以收听具有 IsIndeterminate
属性,可用于查看滚动是否已停止并且可以使用这些决定您是否有时间获取更多数据,或者只是在项目源中放置一些占位符值.您可能还具有item来源属性,并且由于您想进行自己的虚拟化-尽管您可以将ISupportIncremental
用作(希望)一个很好的示例,但您实际上并不需要关心ISupportIncremental
.您将实现自己的虚拟化面板和源列表. 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屋!