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