WPF Reflections

Nov 23 2007   3:33PM GMT

Items Control – useful tip



Posted by: MarkWPF
Tags:
WPF

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

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: