Search code examples
wpflayoutmeasureoverridearrangeoverride

Why does ArrangeOverride recalculate the final size


For myself, It would be logic if MeasureOverride calculates the size of the FrameworkElement and ArrangeOverride just positions the child elements. But ArrangeOverride does not only arrange the child elements. It does also calculate the size of the FrameworkElement again which I do not understand. Why can't MeasureOverride calculate the final size and thats it?


Solution

  • Because your element is potentially not the only one on the screen.

    Layout is not that simple. WPF has to work out the actual physical space it has to use, then calculate how much space each element wants, scale the requested amount if it can, then apply it. Additionally some elements may want to make changes based on the exact amount of space allocated.

    This previous answer of mine gives it to you as an analogy.