wpf - CollectionViewSource Filtering Event vs Property -
what of practical differences between using collectionviewsource.view.filter property opposed collectionviewsource.filter event? there situations use 1 on other or matter of preference?
cheers,
berryl
edit: see docs "if view object comes collectionviewsource object, apply filtering logic setting event handler filter event." although nothing stops setting property on view, , doesn't why so.
the advantage have found far in setting event on collectionviewsource can implement of filtering logic in 1 event handler , use view.refresh (or view.deferrefresh) invoke user changes filtering criteria.
setting filter
event in collectionviewsource mean event called when there no filtering needed make process less efficient.
the official way of using filter
event adding on filtering , removing later when filter cleared.
viewsource.filter += viewsource_filter;
then:
viewsource.filter -= viewsource_filter;
//how know how many events there are!?
if use event, have make sure not adding event each time filter value changes, because apart having redundant events lurking around (=app works harder nothing) have remove events in order clear filter.
thus, there advantage in using filter
property, because can more clear filter setting property null
.
viewsource.view.filter = null;
Comments
Post a Comment