title: Auto Height of tabitem wpf
body: <p>I'd like to create a tabcontrol through code with 2 tabs . I used the code below : </p>
  
  <pre><code>                TabControl tb = new TabControl();
                  tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                  tb.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                  tb.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
                  tb.HorizontalContentAlignment =  System.Windows.HorizontalAlignment.Stretch;
                  ressource_design.initialiserTabControl(tb);
                  tb.Margin = new Thickness(10, 10, 10, 10);
                  TabItem ti1 = new TabItem();
                  ti1.Header = ServicesLangue.RM.GetString("CONTENU_ACCUEIL_LISTE_SAS");
                  ti1.Content = _listeSAS;
                  tb.Items.Add(ti1);
  
                  TabItem ti2 = new TabItem();
                  ti2.Header = ServicesLangue.RM.GetString("CONTENU_ACCUEIL_TBSM");
                  ti2.Content = _tbsm;
                  tb.Items.Add(ti2);
  
                  this.DockPrincipal.Children.Add(tb);
  </code></pre>
  
  <p>But the height of my tabitem is the height of the children control. This is driving me crazy !</p>
  
  <p>I've tried to add the code below in my child control: </p>
  
  <pre><code>Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualWidth}"
                  Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Grid}}, Path=ActualHeight}"
  </code></pre>
  
  <p>But this makes le child control too big !</p>
  
  <p>Note: I have the same problem with the Accordion.</p>
  
  <p>Thanks</p>