I have a ListBox with way too many items in it and the UI is getting slower and slower (virtualization is on, etc). So I was thinking about displaying only the first 20 items and allow to user to navigate through the result set (i.e. ObservableCollection).
Does anybody know if a Pagination mechanism exist for the ObservableCollection? Does anybody has done that before?
Thanks!
This facility is not directly available in the base ObservableCollecton class. You can extend the ObservableCollection and create a custom Collection which does this. You need to hide the original Collection inside this new class and based on a FromIndex and ToIndex give dynamically add the range of items to the class. Override InsertItem and RemoveItem. I am giving a not-tested version bellow. But please take this as just pseudo code.
UPDATE: I have a blog post about this topic on here - http://jobijoy.blogspot.com/2008/12/paginated-observablecollection.html and the source code is uploaded to Codeplex.