title: WPF Layout: Textbox growing inside Tabcontrol
body: <p><a href="https://stackoverflow.com/questions/3720855/stopping-wpf-textbox-from-growing-with-text">Both</a> of <a href="http://social.msdn.microsoft.com/forums/en-US/wpf/thread/a5a654ee-a7e6-4f63-be57-225d2d2fc164" rel="nofollow noreferrer">these</a> questions say that to bind a stretching textbox to container width/height and not grow with user input, you should user a placeholder border and bind to its actual height/width.</p>
  
  <p>This only sort of works though. It does stop the textbox from growing with user input, but the textbox will only resize to grow, it will never resize to shrink. If you use RenderSize it will grow and shrink, but it will grow with user input again. Also, adding an additional element to bind width/height to seems a bit hacky. Is there a better solution?</p>
  
  <p>This seems like it should be the default behavior of stretching textboxes.</p>
  
  <p><strong>EDIT</strong>: Here is the XAML (including Aaron's suggestion below)</p>
  
  <pre><code>&lt;TabControl HorizontalAlignment="Stretch" Margin="5,15,5,5" Name="tabControl2" VerticalAlignment="Stretch" MinHeight="80"&gt;
                              &lt;TabItem Header="Description" Name="tabItem2" FontSize="14" IsEnabled="True"&gt;
                                  &lt;Grid&gt;
                                      &lt;Border Name="b_desc"/&gt;
                                      &lt;TextBox HorizontalAlignment="Stretch" Margin="0" Name="textBox5" 
                                               VerticalAlignment="Stretch" FontSize="12" TextWrapping="Wrap" 
                                               AutoWordSelection="True" VerticalScrollBarVisibility="Auto" 
                                               AcceptsReturn="True" 
                                               Width="{Binding ElementName=b_desc, Path=ActualWidth}" 
                                               Height="{Binding ElementName=b_desc, Path=ActualHeight}" 
                                               MaxWidth="{Binding ElementName=b_desc, Path=Width}" 
                                               MaxHeight="{Binding ElementName=b_desc, Path=Height}" /&gt;
                                  &lt;/Grid&gt;
                              &lt;/TabItem&gt;
                          &lt;/TabControl&gt;
  </code></pre>
  
  <p><strong>EDIT2</strong>: I am not sure if it makes a difference, but these elements are the content of a TabControl bound to a collection of ViewModels. See <a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx#id0090030" rel="nofollow noreferrer">This Article</a> for an example of the pattern.</p>