Best user-interface questions in March 2012

Can give me an example that when should use UIElement.UpdateLayout()?

5 votes

I was reading about this UpdateLayout() method in MSDN.

It says:

Ensures that all visual child elements of this element are properly updated for layout.

But I don't understand what is meant by layout not updated properly.

I have been working with Silverlight/WPF for over a year, but I still haven't used this method once.

So can someone give me an example that will require use of this method? So I can really understand what it does and when I should use it?

You might want to call this if you need a control to immediately complete its layout so that you can do something based on that. For example, you might call UpdateLayout on a child control so that it gets an ActualHeight and ActualWidth, if you want do do something else based on that (eg position it, or draw something with a corresponding size).