jeudi 16 avril 2015

Sorting and Filtering a collection in a Paged ListBox


Vote count:

0




I have a database with 10,000 items, to which you can add and remove while the app is running.


I have a ListBox that displays at most 100 items, and supports paging.


You can filter and sort on the 10,000 items, which needs to be immediately reflected in the listbox.


I have a button that randomly selects an item as long as it passes the filters.


What is the best set of collections/views to use for this kind of operation?


So far, my first step will be to create an ObservableCollection of ALL items in the database which we will call MainOC.


Then create a List of all items that match the filter by parsing MainOC which we will call FilteredList.


Then create a ListCollectionView based on the above List that holds the first 100 items.


CONS:



  • You have to recreate the ListCollectionView every time a sort operation is applied.

  • You have to recreate the ListCollectionView every time you page.

  • You have to recreate the ListCollectionView every time a filter is changed.

  • You have to recreate the ListCollectionView every time an item is added or removed to MainOC.


Is there a better approach that I am missing?


For example, I see that you can apply filters to a ListCollectionView. Should I populate my ListCollectionView with all 10,000 items? But then how can I limit how many items my ListBox is displaying?


Should I be doing my filtering and sorting directly against the database? I could build FilteredList directly off the database and create my ListCollectionView based off that, but this still has all the cons listed above.


Looking for any input you can provide!



asked 4 mins ago

Julien

324






Sorting and Filtering a collection in a Paged ListBox

Aucun commentaire:

Enregistrer un commentaire