title: Prevent RowHeight = Auto from Stretching my Grid?
body: <p>In my scenario, the end user customizes his or her user interface by breaking it into rows and defining the height rule for those rows (fixed, fill space, fit content).  I implement this using the WPF Grid.</p>
  
  <p>The Grid starts filling the entire screen, and should not get any bigger - the user MUST be able to see the entire Grid at all times (scroll bars WITHIN rows are okay, but not scroll bars for the entire grid).</p>
  
  <p>The crux of my problem: When the user creates one or more "auto" sized rows, the content in those rows can force the size of the entire grid to expand, introducing scroll bars, even when I've set the max height of the grid to a fixed number.</p>
  
  <p>It gets worse when a star-sized row is involved, because once the grid is stretched a little, that star-sized row fills the available space, so the grid is PERMANENTLY stretched even when the auto-size row later shrinks.</p>
  
  <p>I need to find a way to restrict "auto" rows so that they expand and shrink as needed, BUT the total actual height of all rows is never larger than the entire grid.</p>
  
  <p>To illustrate, I have this grid with fixed max height, and rows representing all size modes.</p>
  
  <p></p>
  
  <pre><code>&lt;Grid.RowDefinitions&gt;
      &lt;RowDefinition Height="Auto"/&gt;
      &lt;RowDefinition Height="Auto"/&gt;
      &lt;RowDefinition Height="200"/&gt;
      &lt;RowDefinition Height="*"/&gt;
  &lt;/Grid.RowDefinitions&gt;
  
  &lt;ScrollViewer VerticalScrollBarVisibility="Auto"&gt;
      &lt;TextBlock&gt;
          abc&lt;LineBreak/&gt;
          abc&lt;LineBreak/&gt;
          abc&lt;LineBreak/&gt;
          abc&lt;LineBreak/&gt;
          abc&lt;LineBreak/&gt;                    
      &lt;/TextBlock&gt;
  &lt;/ScrollViewer&gt;
  </code></pre>
  
  <p></p>
  
  <p>In this example, as the "abc" text block expands, the total height of the grid stretches beyond the fixed "300" maximum height.  How can I prevent this behavior to guarantee the maximum height of the grid, while keeping the flexibility of the auto-size rows?</p>