title: Stackpanel: Height vs ActualHeight vs ExtentHeight vs ViewportHeight vs DesiredSize vs RenderSize
body: <p>i want to know the height of all items my <code>StackPanel</code>. </p>
  
  <p>What is the difference between:</p>
  
  <ul>
  <li><a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.height.aspx"><code>Height</code></a> - Gets or sets the suggested height of the element. </li>
  <li><a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.actualheight.aspx"><code>ActualHeight</code></a> - Gets the rendered height of this element. (<em>readonly</em>)</li>
  <li><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.extentheight.aspx"><code>ExtentHeight</code></a> - Gets a value that contains the vertical size of the extent. (<em>readonly</em>)</li>
  <li><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.viewportheight.aspx"><code>ViewportHeight</code></a> - Gets a value that contains the vertical size of the content's viewport. (<em>readonly</em>)</li>
  <li><a href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.desiredsize.aspx"><code>DesiredSize</code></a> - Gets the size that this element computed during the measure pass of the layout process. (<em>readonly</em>)</li>
  <li><a href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.rendersize.aspx"><code>RenderSize</code></a> - Gets (or sets, but see Remarks) the final render size of this element.</li>
  </ul>
  
  <hr>
  
  <p>From MSDN:</p>
  
  <blockquote>
    <p><strong><a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.height.aspx">Height</a></strong><br>
    Gets or sets the suggested height of the element. </p>
    
    <p>Property value: <code>Double</code> - The height of the element, in device-independent units (1/96th inch per unit).</p>
    
    <p>The height of the element, in device-independent units (1/96th inch per unit).</p>
  </blockquote>
  
  <p>&nbsp;</p>
  
  <blockquote>
    <p><strong><a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.actualheight.aspx">ActualHeight</a></strong> (<em>readonly</em>)<br>
    Gets the rendered height of this element.  </p>
    
    <p>Property value: <code>Double</code> - The element's height, as a value in device-independent units (1/96th inch per unit). </p>
    
    <p>This property is a calculated value based on other height inputs, and the layout system. The value is set by the layout system itself, based on an actual rendering pass, and may therefore lag slightly behind the set value of properties such as <a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.height.aspx">Height</a> that are the basis of the input change.</p>
    
    <p>Because ActualHeight is a calculated value, you should be aware that there could be multiple or incremental reported changes to it as a result of various operations by the layout system. The layout system may be calculating required measure space for child elements, constraints by the parent element, and so on.</p>
  </blockquote>
  
  <p>&nbsp;</p>
  
  <blockquote>
    <p><strong><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.extentheight.aspx">ExtentHeight</a></strong> (<em>readonly</em>)<br>
    Gets a value that contains the vertical size of the extent.  </p>
    
    <p>Property height: <code>Double</code> - A Double that represents the vertical size of the extent.</p>
    
    <p>The returned value is described in Device Independent Pixels.</p>
  </blockquote>
  
  <p>&nbsp;</p>
  
  <blockquote>
    <p><strong><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.viewportheight.aspx">ViewportHeight</a></strong> (<em>readonly</em>)<br>
    Gets a value that contains the vertical size of the content's viewport.</p>
    
    <p>Property value: <code>Double</code> - The Double that represents the vertical size of the content's viewport.  </p>
    
    <p>The returned value is described in Device Independent Pixels.</p>
  </blockquote>
  
  <p>&nbsp;</p>
  
  <blockquote>
    <p><strong><a href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.desiredsize.aspx">DesiredSize</a></strong> (<em>readonly</em>)<br>
    Gets the size that this element computed during the measure pass of the layout process.</p>
    
    <p>Property value: <code>Size</code> - The computed size, which becomes the desired size for the arrange pass.</p>
    
    <p>The value returned by this property will only be a valid measurement if the value of the IsMeasureValid property is true.</p>
    
    <p>DesiredSize is typically checked as one of the measurement factors when you implement layout behavior overrides such as ArrangeOverride, MeasureOverride, or OnRender (in the OnRender case, you might check RenderSize instead, but this depends on your implementation). Depending on the scenario, DesiredSize might be fully respected by your implementation logic, constraints on DesiredSize might be applied, and such constraints might also change other characteristics of either the parent element or child element. For example, a control that supports scrollable regions (but chooses not to derive from the WPF framework-level controls that already enable scrollable regions) could compare available size to DesiredSize. The control could then set an internal state that enabled scrollbars in the UI for that control. Or, DesiredSize could potentially also be ignored in certain scenarios.</p>
  </blockquote>
  
  <p>&nbsp;</p>
  
  <blockquote>
    <p><strong><a href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.rendersize.aspx">RenderSize</a></strong>
    Gets the final render size of this element.</p>
    
    <p>Property value: <code>Size</code> - The rendered size for this element.</p>
    
    <p>This property can be used for checking the applicable render size within layout system overrides such as OnRender or GetLayoutClip.</p>
    
    <p>A more common scenario is handling the SizeChanged event with the class handler override or the OnRenderSizeChanged event.</p>
  </blockquote>
  
  <hr>
  
  <p>In my case i want know the <strong>desired</strong> height of all items in the <code>StackPanel</code>.</p>
  
  <p>In other words: i want to know height of all items in the StackPanel (before drawing), and if they were to overflow the panel, i will </p>
  
  <ul>
  <li>delete</li>
  <li>shrink</li>
  <li>scale</li>
  <li>adjust</li>
  </ul>
  
  <p>items to ensure they fit in the <strong>StackPanel</strong>.</p>
  
  <p>Which means i probably want to get the <em>desired</em> height (ExtentHeight? DesiredSize?) during a <em>resize</em> event (<a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.sizechanged.aspx">SizeChanged</a>? <a href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.layoutupdated.aspx">LayoutUpdated</a>? ) - before any drawing happens (so it's faster).</p>
  
  <p>Most of these properties return zero; so obviously there's some understanding of what these properties mean that i don't know and are not explained in the documentation.</p>