Nov 23 2007 3:33PM GMT
Posted by: Mark Shurmer
WPF
Items Control - useful tip
Posted by: Mark Shurmer
When you are updating the items or the collection pointed to by ItemsSource on an ItemsControl (or ListBox or ListView), do you wish you could SuspendLayout and ResumeLayout, like in Windows Forms days?
Well, you can!
What you need to do is call DeferRefresh, like so:
using(dataView.DeferRefresh())
{
dataView.SortDescriptions.Clear();
dataView.SortDescriptions.Add(new SortDescription(headerProperty, GetLastSortDirection(lv)));
}
here i am going to sort a ListView, but don’t want any layout calculations to occur etc
It will stop any updates happening, then do a Refresh() as you go out of scope of the using statement



You must be logged-in to post a comment. Log-in/Register