O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Measure Step

In the measure step, parents ask their children how big they want to be, given the amount of space available. Panels (and children, when appropriate) do this by overriding the MeasureOverride method from FrameworkElement. Here’s an example:

protected override Size MeasureOverride(Size availableSize){  ...  // Ask each child how big it would like to be, given a certain amount of space  foreach (UIElement child in this.Children)  {    child.Measure(new Size(...));    // The child's answer is now in child.DesiredSize    ...  }  ...  // Tell my parent how big I would like to be given the passed-in availableSize  return new Size(...);}

All children can be accessed via the panel’s Children collection (a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required