title: Measure Control with double.PositiveInfinity WPF
body: <p>I am working on a custom control that has a custom panel and inside the custom panel I have a small and simple <code>MeasureOverride</code> method that passes the size of <code>double.PositiveInfinity</code> to its children <code>MeasureOverride</code> method. The custom panel should take care of the layout and it should make children bigger or smaller depending on window size.</p>
  
  <p>If you have dealt with controls you should then know how wpf layout system works and that basically every child calls MeasureOverride which calls MeasureOverride of childs children and so on.</p>
  
  <p>Now the problem is that when I resize the window, the custom panel does get receive the flag to do the measure again hence the <code>MeasureOverride</code> does get called again but this time while passing the <code>double.PositiveInfitinty</code> size to its children, the children <code>MeasureOverride</code> doesn't get called at all (but the method should be called according to the definition of WPF layout system). Why is that so? I always thought when I call the <code>MeasureOverride</code> on a parent that it children will also be forced to do the measure.</p>
  
  <p>Obviously I am wrong so could somebody explain me how does a control/child know when to measure again?</p>
  
  <p>By the way I am passing the size of <code>double.PositiveInfinity</code> to the children to tell them to take as much space as needed.</p>
  
  <p>Code:</p>
  
  <pre><code>protected override Size MeasureOverride(Size availableSize)
  {
   double x;
   double y;
   var children = this.InternalChildren;
   for (int i = 0; i &lt; children.Count; i++)
       {
         UIElement child = children[i];
         child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity);
         y += child.DesiredSize.Height;
         x = Math.Max(x, child.DesiredSize.Width);
        }
   return new Size(x, y);
  }
  </code></pre>
  
  <p>Code is simple. I dont get it why the children doesnt get measured again. And sorry if i have misspelled something in code.</p>