WPF MeasureOverride and Desired Size

I’ve been struggling to get a custom layout working for an items control due to a large number of Double.Nan being exposed. Finally I found the answer in the MSDN docs (that’ll teach me).

http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.measureoverride.aspx

It appears there are three sizes for each WPF framework element.

Height, Width – As defined at design time

ActualHeight, ActualWidth – Where the sizes will end up once the calls to elem.Arrange(…) via ArrangeOverride of the Collection control have completed

and introducing..

DesiredSize.Height, Desized.Width – which is the value that was returned in each UIElements.MeasureOverride(…)

This means that for complex layouts you will need to calculate the entire appearance at Measure time, and then again and Arrange time.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s