title: Bind Pivot Header Template
body: <p>I have a <code>Pivot Control</code> and three <code>PivotItems</code> added in <code>Blend</code>. Each <code>PivotItem</code> has a <code>ViewModel</code> as it's <code>DataContext</code>. Each <code>ViewModel</code> has a string property <code>Title</code>. I want to edit the <code>Header Template</code>, create a <code>TextBlock</code> and bind it's <code>Text</code> property to <code>Title</code>, but for some reason it doesn't work. I am sure it's because the <code>DataContext</code> of the <code>Header Template</code> is null, but I thought it would be inherited from the specific <code>PivotItem</code>. This is the <code>xaml</code> code for the Header Template. </p>
  
  <pre><code>    &lt;DataTemplate x:Key="HeaderTemplate"&gt;
          &lt;Grid Height="47" Width="354"&gt;
              &lt;TextBlock Margin="8,0,64,8" TextWrapping="Wrap" Text="{Binding Title}" d:LayoutOverrides="Width" FontSize="24" Foreground="Red"/&gt;
          &lt;/Grid&gt;
      &lt;/DataTemplate&gt;
  
  
  
      &lt;controls:Pivot TitleTemplate="{StaticResource TitleTemplate}" HeaderTemplate="{StaticResource HeaderTemplate}"&gt;
          &lt;!--Pivot item one--&gt;
          &lt;controls:PivotItem DataContext="{Binding Home, Mode=OneWay}"&gt;
              &lt;Grid&gt;
                  &lt;ListBox x:Name="listBox" ItemsPanel="{StaticResource HomeItemsPanel}" ItemTemplate="{StaticResource HomeItemTemplate}" ItemsSource="{Binding Tiles}"&gt;
                      &lt;i:Interaction.Triggers&gt;
                          &lt;i:EventTrigger EventName="SelectionChanged"&gt;
                              &lt;GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding OnSelectionChanged}" CommandParameter="{Binding SelectedIndex, ElementName=listBox}"/&gt;
                          &lt;/i:EventTrigger&gt;
                      &lt;/i:Interaction.Triggers&gt;
                  &lt;/ListBox&gt;
              &lt;/Grid&gt;
          &lt;/controls:PivotItem&gt;
          &lt;controls:PivotItem Margin="0,8,0,1"&gt;
              &lt;Grid/&gt;
          &lt;/controls:PivotItem&gt;
  
          &lt;!--Pivot item two--&gt;
          &lt;controls:PivotItem DataContext="{Binding More, Mode=OneWay}"&gt;
              &lt;Grid/&gt;
          &lt;/controls:PivotItem&gt;
      &lt;/controls:Pivot&gt;
  </code></pre>
  
  <p>I want to create a more complex <code>Header Template</code> but for now I am testing if I can bind it, before proceeding on with something more than just a TextBlock. I know that I could use a <code>List</code> of <code>ViewModels</code> for the <code>PivotControl.ItemSource</code>, but then I would have to use a <code>DataTemplateSelector</code> and so on, and I don't want that.</p>
  
  <p>So I guess my question is this, how can I make the HeaderTemplate inherit the DataContext of the according <code>PivotItem</code>?
  Thank you.</p>