title: how to get the height of multiline textbox increased automatically as form get stretched vertically in WPF
body: <p>I m using following hierarchy</p>
  
  <pre><code> WPF form 
     - Grid
       - GroupBox
          - Grid 
            -  multiline textbox
  </code></pre>
  
  <p>can you tell me how  to get the height of multiline textbox increased automatically as the form gets stretched vertically in WPF. Form is resizable by the user.</p>
  
  <pre><code>   &lt;Window x:Class="WPFApp.UserFunctions"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
          xmlns:rp="clr-namespace:WPFApp" 
          WindowStartupLocation="CenterScreen"
          ResizeMode="CanResize"
          Title="User Functions" ShowInTaskbar="False" 
          MinWidth="770" MinHeight="570" Width="770" Height="550"
          Icon="/WPFApp;component/images/Globe.png" 
          Name="frmUserFunctions" Closing="OnWindowClosing"&gt;
          &lt;Grid Margin="2" VerticalAlignment="Stretch" Height="auto"&gt;
              &lt;Grid.Resources&gt;
                  &lt;ResourceDictionary&gt;
                      &lt;ResourceDictionary.MergedDictionaries&gt;
                          &lt;ResourceDictionary Source="../Style/StyleDictionary.xaml"/&gt;
                      &lt;/ResourceDictionary.MergedDictionaries&gt;
                  &lt;/ResourceDictionary&gt;
              &lt;/Grid.Resources&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="auto" /&gt;
                  &lt;RowDefinition Height="auto" MinHeight="40" /&gt;
                  &lt;RowDefinition Height="auto" MinHeight="40" /&gt;
                  &lt;RowDefinition Height="auto" MinHeight="40" /&gt;
                  &lt;RowDefinition Height="auto" MinHeight="40" /&gt;
                  &lt;RowDefinition Height="auto" MinHeight="40" /&gt;
                  &lt;RowDefinition Height="auto" MinHeight="40" /&gt;
                  &lt;RowDefinition Height="auto" MinHeight="40" /&gt;
              &lt;/Grid.RowDefinitions&gt;
              &lt;Label Name="lblErrMsgDesp" Foreground="Red" FontWeight="Bold" Visibility="Collapsed" 
                      Content="Error"   Margin="5,5,5,5" Grid.Row="0" &gt;&lt;/Label&gt;
  
              &lt;GroupBox Name="grpCFL" Margin="2" Width="auto" VerticalAlignment="Top" Grid.Row="1" Grid.RowSpan="2"&gt;
                  &lt;Grid&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition/&gt;
                          &lt;RowDefinition/&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;StackPanel Orientation="Vertical" Margin="2" Width="auto" Grid.Row="0" VerticalAlignment="Top"&gt;
                          &lt;StackPanel Margin="2" Width="auto"&gt;
                              &lt;TextBlock Name="tbCFLStaticMessage" Text=""
                                         Foreground="Black"  Margin="2" &gt;&lt;/TextBlock&gt;
                          &lt;/StackPanel&gt;
                          &lt;StackPanel Orientation="Horizontal" Margin="2" Width="auto"&gt;
                              &lt;Button  Name="btnOpenCFL" Style="{DynamicResource btnMainNew}" 
                                                   Click="OnClickCFLBrowse" Margin="5" /&gt;
  
                              &lt;Button  Name="btnNewCFL" Style="{DynamicResource btnMainNew}" 
                                                   Click="OnClickNewCFL" Margin="5" /&gt;
  
                              &lt;Button  Name="btnSaveCFL" Style="{DynamicResource btnMainNew}"
                                                   Click="OnClickSaveCFL" Margin="5" /&gt;
                          &lt;/StackPanel&gt;
                      &lt;/StackPanel&gt;
  
                      &lt;StackPanel Orientation="Vertical" Margin="2" Width="auto" Grid.Row="1" 
                                     VerticalAlignment="Top"&gt;
                          &lt;TextBlock Name="tbCFLFilePath" Foreground="Black"  Margin="2" &gt;&lt;/TextBlock&gt;
                          &lt;Border BorderThickness="1" BorderBrush="LightGray" Margin="2"&gt;
                              &lt;TextBlock MinWidth="660"  IsEnabled="False" Margin="1" Name="tbCFLFileName" 
                                         FontSize="13" Foreground="Black" MinHeight="20"/&gt;
                          &lt;/Border&gt;
                      &lt;/StackPanel&gt;
  
                  &lt;/Grid&gt;
              &lt;/GroupBox&gt;
              &lt;GroupBox Name="grpFunctions"  Margin="2" VerticalAlignment="Stretch" Height="auto"
                        HorizontalAlignment="Stretch" Grid.Row="3" Grid.RowSpan="5"&gt;
                  &lt;Grid  VerticalAlignment="Stretch" Height="auto"&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition/&gt;
                          &lt;RowDefinition/&gt;
                          &lt;RowDefinition/&gt;
                          &lt;RowDefinition/&gt;
                          &lt;RowDefinition/&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="*"/&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
  
                      &lt;Border BorderThickness="0" BorderBrush="LightGray" Margin="2" Grid.Row="0"&gt;
                          &lt;Grid Margin="2" &gt;
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Width="auto"/&gt;
                                  &lt;ColumnDefinition Width="auto"/&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
  
                              &lt;StackPanel Orientation="Horizontal" &gt;
                                  &lt;Button Style="{DynamicResource btnMainNew}"  
                                  HorizontalAlignment="Left" Name="btnNew" Margin="2,5,5,5" IsEnabled="False"
                                  Click="OnClickNew"&gt;&lt;/Button&gt;
                                  &lt;Button Style="{DynamicResource btnMainNew}" 
                                  HorizontalAlignment="Right" Name="btnEdit" Margin="5,5,5,5"  IsEnabled="False"
                                  Click="OnClickEdit"&gt;&lt;/Button&gt;
                                  &lt;Button Style="{DynamicResource btnMainNew}" 
                                  HorizontalAlignment="Right" Name="btnDelete" Margin="5,5,5,5"  IsEnabled="False"
                                  Click="OnClickDelete"&gt;&lt;/Button&gt;
                              &lt;/StackPanel&gt;
                              &lt;StackPanel Grid.Column="1" Orientation="Horizontal" 
                                  HorizontalAlignment="Right" Margin="2"&gt;
  
                                  &lt;Button Style="{DynamicResource btnMainNew}" Content="Clear"
                                  HorizontalAlignment="Right" Name="btnReset" Margin="5,5,5,5" 
                                  Click="OnClickReset"/&gt;
  
                                  &lt;Button Style="{DynamicResource btnMainNew}" Content="Close" Click="OnClickClose"
                                  HorizontalAlignment="Right" Name="btnCancel" Margin="5,5,5,5" /&gt;
                              &lt;/StackPanel&gt;
                          &lt;/Grid&gt;
                      &lt;/Border&gt;
  
                      &lt;StackPanel Grid.Row="1" Margin="2" Orientation="Vertical" Name="spSelectFunction"
                        Width="auto"  VerticalAlignment="Top"&gt;
                          &lt;TextBlock Name="tbSelectFunction" Foreground="Black" Margin="5,2,2,2" Width="auto"/&gt;
                          &lt;ComboBox Style="{DynamicResource cboBox}" IsEnabled="False" Margin="5,2,2,2" MaxWidth="1650"
                            Name="cmbFunctionsList" SelectionChanged="OnFunctionsListSelectionChanged"
                        VerticalAlignment="Center"  MinHeight="25"  Width="auto"/&gt;
                      &lt;/StackPanel&gt;
  
                      &lt;StackPanel Orientation="Vertical" Grid.Row="1" Name="spFunctionName"  Margin="2" 
                          VerticalAlignment="Top" Visibility="Collapsed"&gt;
                          &lt;TextBlock Name="tbFunctionName" Foreground="Black"  Width="auto"  Margin="5,2,2,2"&gt;&lt;/TextBlock&gt;
                          &lt;TextBox  Style="{DynamicResource txtBox}"  Width="auto"
                                   AcceptsReturn="False" Name="txtFunctionName" VerticalAlignment="Center" 
                                   TextChanged="OnFunctionNameTextChanged" Margin="5,2,2,2" MaxWidth="1650"
                                   VerticalScrollBarVisibility="Auto" TextWrapping="Wrap"  /&gt;
                      &lt;/StackPanel&gt;
  
                      &lt;StackPanel Grid.Row="2"  Margin="2" Orientation="Vertical" &gt;
                          &lt;Grid&gt;
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition  Width="115"/&gt;
                                  &lt;ColumnDefinition  Width="115"/&gt;
                                  &lt;ColumnDefinition  Width="115"/&gt;
                                  &lt;ColumnDefinition  Width="30"/&gt;
                                  &lt;ColumnDefinition  /&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
                              &lt;Grid.RowDefinitions&gt;
                                  &lt;RowDefinition/&gt;
                                  &lt;RowDefinition/&gt;
                                  &lt;RowDefinition/&gt;
                              &lt;/Grid.RowDefinitions&gt;
  
                              &lt;TextBlock Name="tbDataTypes" Foreground="Black"  Grid.Column="0" Grid.Row="0" Margin="5,2,2,2" &gt;
                              &lt;/TextBlock&gt;
                              &lt;TextBlock Name="tbOccurences" Foreground="Black"  Grid.Column="1" Grid.Row="0" Margin="5,2,2,2"&gt;
                              &lt;/TextBlock&gt;
                              &lt;TextBlock Name="tbParametersSize" Foreground="Black"  Grid.Column="2" Grid.Row="0" Margin="5,2,2,2"&gt;
                              &lt;/TextBlock&gt;
                              &lt;TextBlock Name="tbGeneratedSignatureLabel" Foreground="Black"  Grid.Row="0" Grid.Column="3" Grid.ColumnSpan="2" Margin="5,2,2,2" /&gt;
                              &lt;ComboBox Name="cmbDataTypes" Grid.Row="1" Grid.Column="0" Margin="5" 
                                Width="105" Style="{DynamicResource cboBox}" ItemsSource="{Binding}"
                                SelectionChanged="OncmbDataTypesSelectionChanged" MinHeight="25" 
                                MaxWidth="105" MinWidth="105"&gt;
                              &lt;/ComboBox&gt;
  
                              &lt;ComboBox Name="cmbOccurences" Grid.Row="1" Grid.Column="1" Margin="5" 
                                HorizontalAlignment="Left" Width="105" ItemsSource="{Binding}"
                                Style="{DynamicResource cboBox}" 
                                MinHeight="25" MaxWidth="105" MinWidth="105"
                                SelectionChanged="OncmbOccurencesSelectionChanged"&gt;
                              &lt;/ComboBox&gt;
  
                              &lt;ComboBox Name="cmbParametersNo" Grid.Row="1" Grid.Column="2" Margin="5" 
                                HorizontalAlignment="Left" Width="105" ItemsSource="{Binding}"
                                Style="{DynamicResource cboBox}" 
                                MinHeight="25" MaxWidth="105" MinWidth="105"
                                SelectionChanged="OncmbParametersNoSelectionChanged"&gt;
                              &lt;/ComboBox&gt;
                              &lt;TextBlock Margin="0" Name="tbGeneratedSignatureLocal" Text="local:"  Grid.Row="1" Grid.Column="3"
                                             Foreground="Black" TextDecorations="None" VerticalAlignment="Center" /&gt;
                               &lt;TextBlock Margin="0" Name="tbGeneratedSignature" Grid.Column="4" Grid.Row="1"
                                             Foreground="Black" TextDecorations="None" VerticalAlignment="Center"/&gt;
  
                          &lt;/Grid&gt;
                      &lt;/StackPanel&gt;
  
                      &lt;StackPanel Grid.Row="3" Name="grpDescription" Orientation="Vertical"  Width="auto"
                        VerticalAlignment="Top"  Margin="2"&gt;
                          &lt;TextBlock Name="tbDescription" Margin="5,2,2,2" Foreground="Black"&gt;&lt;/TextBlock&gt;
                          &lt;TextBox   Style="{DynamicResource txtBox}" IsEnabled="False" Margin="5,2,2,2"
                        AcceptsReturn="False" Name="txtDescription" VerticalAlignment="Center" MaxWidth="1650"
                        VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" MaxLines="1" IsReadOnly="False" /&gt;
                      &lt;/StackPanel&gt;
  
                      &lt;Grid  Grid.Row="4" Name="grpProgram" VerticalAlignment="Stretch" Margin="2"  MinHeight="120" 
                                  HorizontalAlignment="Stretch" &gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition/&gt;
                              &lt;RowDefinition Height="auto"/&gt;
                          &lt;/Grid.RowDefinitions&gt;
  
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="*"/&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
  
                          &lt;TextBlock Name="tbProgram" Foreground="Black" Grid.Row="0"  Margin="5,2,2,2"  &gt;&lt;/TextBlock&gt;
  
   &lt;TextBox Grid.Row="1" IsEnabled="False" Margin="5,2,2,0"  AcceptsReturn="True" Name="txtProgram"
                                   VerticalAlignment="Stretch" Width="auto"
                            VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" MinHeight="100" MaxWidth="1650"  Height="auto" /&gt;
  
                      &lt;/Grid&gt;
  
                  &lt;/Grid&gt;
              &lt;/GroupBox&gt;
          &lt;/Grid&gt;
      &lt;/Window&gt;
  </code></pre>