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())
{
dataView.SortDescriptions.Clear();
SortDescription sd = new SortDescription(newField, ListSortDirection.Ascending);
dataView.SortDescriptions.Add(sd);
}
source: CollectionView.DeferRefresh() : My new best friend
Technorati tags: WPF,CollectionView,CollectionViewSource