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
问题:
回答1:
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!