title: WPF DataTemplate Binding
body: <p>I discovered when using a ContentTemplate/DataTemplate in a WPF TabControl my Bindings will not work anymore.</p>
  
  <p>I have set up a small example to illustrate:</p>
  
  <pre><code>&lt;Window x:Class="HAND.BindingExample"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="BindingExample" Height="506" Width="656"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      &gt;
  &lt;Grid&gt;
      &lt;TabControl HorizontalAlignment="Left" Height="381"  VerticalAlignment="Top" Width="608"&gt;
          &lt;TabItem Header="TabItem"&gt;
              &lt;Label Content="{Binding Path=myString}"/&gt;
          &lt;/TabItem&gt;
          &lt;TabItem Header="TabItem"&gt;
              &lt;TabItem.ContentTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Label Content="{Binding Path=myString}"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/TabItem.ContentTemplate&gt;
          &lt;/TabItem&gt;
      &lt;/TabControl&gt;
  &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Tab1 works as expected, Tab2 is empty.</p>
  
  <p>the code behind:</p>
  
  <pre><code>using System.Windows;
  
  namespace HAND
  {
      public partial class BindingExample : Window
      {
          public string myString { get; set; }
  
          public BindingExample()
          {
              myString = "Hello Stackoverflow";
  
              InitializeComponent();
          }
      }
  }
  </code></pre>