title: UniformGrid with per-row MinHeight
body: <p>My application displays multiple items in an <code>ItemsControl</code> that uses a <code>UniformGrid</code> as its <code>ItemsPanel</code>.</p>
  
  <pre><code>&lt;ItemsControl.ItemsPanel&gt;
      &lt;ItemsPanelTemplate&gt;
          &lt;!-- Arrange all items vertically, distribute the space evenly --&gt;
          &lt;UniformGrid Columns="1"/&gt;
      &lt;/ItemsPanelTemplate&gt;
  &lt;/ItemsControl.ItemsPanel&gt;
  </code></pre>
  
  <p>Now each of the items will take as much space as there is and the full width. That's how it should be. But each item must not get smaller than a certain height, say 250 pixels. Therefore, my <code>ItemsControl</code> is put inside a <code>ScrollViewer</code> which will start to scroll if the minimum height doesn't fit on the screen anymore (but fill until then).</p>
  
  <p>Setting each item's <code>MinHeight</code> property to 250 will make it taller but won't change how the <code>UniformGrid</code> arranges them in any way, so they're clipped. That's not the solution.</p>
  
  <p>Setting the entire ItemsControl's or the UniformGrid's <code>MinHeight</code> property does work, but then I need to calculate it from the number of items. A good place to get the updated number of items is to override the <code>OnItemsChanged</code> method in my <code>ItemsControl</code> code-behind. But that won't give me the actual items panel. I have the following code for that in another project, but it always returns null here:</p>
  
  <pre><code>ItemsControl itemsControl = ItemsControl.GetItemsOwner(this);
  </code></pre>
  
  <p>So that doesn't work, too.</p>
  
  <p>Walking the visual tree is probably not an option, too, because it's too late. I need to set the minimum height before that items panel is arranged so that it won't flicker. (I generate complex content on a size change so any late layouting must be avoided.)</p>
  
  <p>What options do I have to get what I need?</p>
  
  <p>I may drop the <code>UniformGrid</code> in favour of something else, if it's possible. Any suggestions?</p>