View swap in WPF

Is there a PagedCollectionView implementation in WPF? It exists in Silverlight, but not in WPF.

If this does not happen, what will be the easiest way to implement this?

+6
source share
2 answers

You can simply take the code from Silverlight one and use it in your WPF project.

+2
source

Or use only the CollectionView class and the "double filter" of your collection

solution found here: Native CollectionView for paging, sorting and filtering

I pasted snipet code here for your convenience:

// obtenir la CollectionView ICollectionView cvCollectionView = CollectionViewSource.GetDefaultView(this.Suivis); if (cvCollectionView == null) return; // filtrer ... exemple pour tests DI-2015-05105-0 cvCollectionView.Filter = p_oObject => { return true; /* use your own filter */ }; // page configuration int iMaxItemPerPage = 2; int iCurrentPage = 0; int iStartIndex = iCurrentPage * iMaxItemPerPage; // dΓ©terminer les objects "de la page" int iCurrentIndex = 0; HashSet<object> hsObjectsInPage = new HashSet<object>(); foreach (object oObject in cvCollectionView) { // break if MaxItemCount is reached if (hsObjectsInPage.Count > iMaxItemPerPage) break; // add if StartIndex is reached if (iCurrentIndex >= iStartIndex) hsObjectsInPage.Add(oObject); // increment iCurrentIndex++; } // refilter cvCollectionView.Filter = p_oObject => { return hsObjectsInPage.Contains(p_oObject); }; 
0
source

Source: https://habr.com/ru/post/900746/


All Articles