CollectionViewSource: avoid useless refresh

Interacting with CollectionViewSource is an effective way to implement special behaviours our end users very eager of.
CollectionViewSource showes almost immediately its result, but when you move big quantity of data, it might update too often;
end users’ feedback might be something … inelegant (ie: why list is flashing ?)

A simple solution is DeferRefresh() method, postpone useless refresh and will show last one.
Sample code might be:

ICollectionView dataView = CollectionViewSource.GetDefaultView(listBox.ItemsSource);
using (dataView.DeferRefresh())
   SortDescription sd = new SortDescription(newField, ListSortDirection.Ascending);

source: CollectionView.DeferRefresh() : My new best friend

Technorati tags: WPF,CollectionView,CollectionViewSource

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: