title: ScrollViewer does not work with grid in wpf
body: <p>I want to have a vertical scrollbar on my grid, which seems straightforward enough but for some reason it just won't work. When I set VerticalScrollBarVisibility to visible it shows up but does nothing. When it is set to auto it does not show up at all.</p>
  
  <p>I have read the advice on this website but it doesn't seem to work for me. I know that rows should be set to fixed height or * and I have a combination of both. I also tried setting the max height of the grid and the height of the scroll bar, as was suggested, but neither of those worked either. </p>
  
  <p>This is how I have it set up (the grid is within a tab):</p>
  
  <pre><code>&lt;/TabItem.Header&gt;
  &lt;ScrollViewer VerticalScrollBarVisibility="Auto"&gt;
  &lt;Grid Name="CSGrid"&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="400"/&gt;
          &lt;ColumnDefinition Width="200"/&gt;
          &lt;ColumnDefinition Width="200"/&gt;
          &lt;ColumnDefinition Width="200"/&gt;
          &lt;ColumnDefinition Width="Auto"/&gt;
          &lt;ColumnDefinition Width="*"/&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="20"/&gt;
          &lt;RowDefinition Height="5"/&gt;
          &lt;RowDefinition Height="1"/&gt;
          &lt;RowDefinition Height="20"/&gt;
          &lt;RowDefinition Height="20"/&gt;
          &lt;RowDefinition Height="20"/&gt;
          ...
  </code></pre>
  
  <p>I then have a large number of rows whose contents I set through C# code, if that makes a difference. All of the heights are set to 20. After that I also have a number of rectangles and textblocks in the grid, nothing that I would imagine would be problematic - unless they would make a difference somehow? </p>
  
  <p>In the code I add text to the rows like this:</p>
  
  <pre><code>TextBlock hist1 = new TextBlock();
  TextBlock hist2 = new TextBlock();
  TextBlock hist3 = new TextBlock();
  TextBlock hist4 = new TextBlock();
  TextBlock hist5 = new TextBlock();
  </code></pre>
  
  <p>string[] allHist = File.ReadAllLines("MedicalHistory.txt");</p>
  
  <pre><code>hist1.Text = allHist[0];
  hist2.Text = allHist[1];
  hist3.Text = allHist[2];
  hist4.Text = allHist[3];
  hist5.Text = allHist[4];
  
  CSGrid.Children.Add(hist1);
  CSGrid.Children.Add(hist2);
  CSGrid.Children.Add(hist3);
  CSGrid.Children.Add(hist4);
  CSGrid.Children.Add(hist5);
  
  Grid.SetColumn(hist1, 0);
  Grid.SetColumn(hist2, 0);
  Grid.SetColumn(hist3, 0);
  Grid.SetColumn(hist4, 0);
  Grid.SetColumn(hist5, 0);
  
  Grid.SetRow(hist1, 5);
  Grid.SetRow(hist2, 6);
  Grid.SetRow(hist3, 7);
  Grid.SetRow(hist4, 8);
  Grid.SetRow(hist5, 9);
  </code></pre>
  
  <p>Any help would be greatly appreciated</p>