Reputation: 4335
I have some experience of using CollectionViewSource, and can implement sorting, grouping, and filtering with MVVM pattern. But I am curious when is CollectionViewSource.Filter event raised. My usual way is like MSDN, but this is only registering the event, unlike Button.Click I don't see any where to raise this event, such as by keyboard or mouse. So could anyone explain it? Thanks!
Upvotes: 0
Views: 2144
Reputation: 4481
You can reevaluate the filter manually if your filter's criteria changes by calling ICollectionView.Refresh
in your view model code:
collectionViewSource.View.Refresh();
You can prevent calling the filter repeatedly when you're doing batch modifications:
using (collectionViewSource.DeferRefresh())
{
// update your collection in here
}
Upvotes: 4