title: vertical scrollbar not appearing in datagrid inside usercontrol in wpf
body: <p>I have a user control in WPF that has a DataGrid.
  I add this user control in a Window inside a TabItem of TabControl.
  The Vertical scrollbar is not getting visible. I resized the window and it seems the user control is taking its complete height after considering height of DataGrid.</p>
  
  <p>How to make the vertical scrollbar appear and still keep the height of DataGrid to auto depending on the height available as per height of the user control and window?</p>
  
  <p>EDIT:
  Main Window:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Window&gt;
    &lt;Grid&gt;
      &lt;TabControl Name="tc"
                  SelectionChanged="tc_SelectionChanged"&gt;
        &lt;TabItem Header="ABC"&gt;
          &lt;local:uc1 /&gt;
        &lt;/TabItem&gt;
        &lt;TabItem Header="DEF"&gt;
          &lt;local:uc2 /&gt;
        &lt;/TabItem&gt;
      &lt;/TabControl&gt;
    &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>User Control:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;UserControl&gt;
    &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
        &lt;RowDefinition Height="30"&gt;&lt;/RowDefinition&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Grid.ColumnDefinitions&gt;
        &lt;ColumnDefinition Width="2*"&gt;&lt;/ColumnDefinition&gt;
        &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
      &lt;/Grid.ColumnDefinitions&gt;
  
      &lt;StackPanel Grid.Row="0"
                  Grid.Column="0"
                  Orientation="Vertical"&gt;
        &lt;StackPanel Orientation="Horizontal"&gt;
          &lt;Button&gt;Add&lt;/Button&gt;
          &lt;Button&gt;Remove&lt;/Button&gt;
          &lt;Button&gt;Refresh&lt;/Button&gt;
        &lt;/StackPanel&gt;
  
        &lt;Label Name="lblTopMessage"&gt;some message&lt;/Label&gt;
  
        &lt;DataGrid Name="dg"
                  IsReadOnly="True"&gt;
          &lt;DataGrid.Columns&gt;
            &lt;DataGridTextColumn Binding="{Binding Name}"
                                Header="Name"
                                Width="*"&gt;&lt;/DataGridTextColumn&gt;
            &lt;DataGridTextColumn Binding="{Binding Value}"
                                Header="Value"
                                Width="130"&gt;&lt;/DataGridTextColumn&gt;
            &lt;DataGridTextColumn Binding="{Binding List}"
                                Header="List"
                                Width="*"&gt;&lt;/DataGridTextColumn&gt;
          &lt;/DataGrid.Columns&gt;
        &lt;/DataGrid&gt;
  
      &lt;/StackPanel&gt;
      &lt;Grid Grid.Row="0"
            Grid.Column="1"
            Name="gridTS"&gt;
        &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
        &lt;/Grid.RowDefinitions&gt;
        &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="100"&gt;&lt;/ColumnDefinition&gt;
          &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
        &lt;/Grid.ColumnDefinitions&gt;
        &lt;TextBlock Name="lblNewSource"
                   Grid.Row="0"
                   Grid.ColumnSpan="2"
                   HorizontalAlignment="Center"
                   Padding="0 5 0 0"
                   FontWeight="Bold"&gt;New Source&lt;/TextBlock&gt;
        &lt;TextBlock Grid.Row="1"
                   Grid.Column="0"
                   Padding="10 10 0 0"&gt;Name:&lt;/TextBlock&gt;
        &lt;TextBlock Grid.Row="2"
                   Grid.Column="0"
                   Padding="10 10 0 0"&gt;Value:&lt;/TextBlock&gt;
        &lt;TextBlock Grid.Row="3"
                   Grid.Column="0"
                   Padding="10 10 0 0"&gt;List:&lt;/TextBlock&gt;
  
        &lt;TextBox Grid.Row="1"
                 Grid.Column="1"
                 Name="txtName"
                 IsEnabled="False"&gt;&lt;/TextBox&gt;
        &lt;ComboBox Grid.Row="2"
                  Grid.Column="1"
                  Name="cbValue"&gt;&lt;/ComboBox&gt;
        &lt;ListBox Grid.Row="3"
                 Grid.Column="1"
                 Name="lbList"&gt;
          &lt;ListBox.ItemTemplate&gt;
            &lt;DataTemplate&gt;
              &lt;CheckBox Margin="3 5 0 3"
                        Content="{Binding Name}"
                        IsChecked="{Binding IsActive}" /&gt;
            &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
        &lt;/ListBox&gt;
  
        &lt;Button Name="btnSave"
                Click="btnSave_Click"
                Grid.Row="4"
                Grid.Column="1"&gt;Save&lt;/Button&gt;
        &lt;TextBlock TextWrapping="WrapWithOverflow"
                   Name="lblMessage"
                   Grid.Row="5"
                   Grid.Column="1"
                   Margin="0 10 10 0"&gt;&lt;/TextBlock&gt;
      &lt;/Grid&gt;
    &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>