title: Modifying TabControl's header
body: <p>So I'm adding my views directly to the <code>TabControl</code>'s Items collection at runtime (instead of creating TabItems around them and addings those TabItems to TabControl). The views expose a property (wrapper around a ViewModel property of the same name) named <code>HasChanges</code> that I want to bind to <code>TabItem</code>'s Header to show a Asterisk (*) sign to identify tabs with unsaved changes, just like VS does. I have already tried using DataTemplates but am having trouble accessing the view object in the <code>DataTemplate</code>. What's the correct way of doing this? Here's one of my several attempts:</p>
  
  <pre><code>&lt;TabControl.ItemTemplate&gt;
      &lt;DataTemplate DataType="UserControl"&gt;
          &lt;StackPanel Orientation="Horizontal" Margin="0" Height="22"&gt;
              &lt;TextBlock VerticalAlignment="Center" Text="{Binding HeaderText, RelativeSource={RelativeSource AncestorType=UserControl}}" /&gt;
              &lt;TextBlock Text="*" Visibility="{Binding HasChanges, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource B2VConverter}}" /&gt;
          &lt;/StackPanel&gt;
      &lt;/DataTemplate&gt;
  &lt;/TabControl.ItemTemplate&gt;
  </code></pre>
  
  <p>Note that I'm trying two different binding methods for the two <code>TextBlock</code>s, none of which is working. My views inherit from <code>UserControl</code> and expose properties <code>HasChanges</code> and <code>HeaderText</code>.</p>