title: Binding WPF menu items to WPF Tab Control Items collection
body: <p>I have a WPF Menu and a Tab control.  I would like the list of menu items to be generated from the collection of TabItems on my tab control. I am binding my tab control to a collection to generate the TabItems.  I have a TabItem style that uses a ContentPresenter to display the TabItem text in a TextBlock.  When I bind the tab items to my menu the menu items are blank.  I am using a Style Setter to set the Menu Item name, but I am not sure what property of the TabItem I would use to set the MenuItem text.  Is there a workaround for my scenario?  Is it possible to bind to the Header property of the tab item, when I do not know the number of tabs in advance?  Below is a copy of my xaml declarations.  Tab Control and items:</p>
  
  <pre><code>&lt;DataTemplate x:Key="ClosableTabItemTemplate"&gt;
          &lt;DockPanel HorizontalAlignment="Stretch"&gt;
              &lt;Button
          Command="{Binding Path=CloseWorkSpaceCommand}"
          Content="X"
          Cursor="Hand"
          DockPanel.Dock="Right"
          Focusable="False"
          FontFamily="Courier" 
          FontSize="9"
          FontWeight="Bold"  
          Margin="10,1,0,0"
          Padding="0"
          VerticalContentAlignment="Bottom"
          Width="16" Height="16"
          Background="Red"
          /&gt;
              &lt;ContentPresenter HorizontalAlignment="Center"
          Content="{Binding Path=DisplayName}"&gt;
                  &lt;ContentPresenter.Resources&gt;
                      &lt;Style TargetType="{x:Type TextBlock}"/&gt;
                  &lt;/ContentPresenter.Resources&gt;
              &lt;/ContentPresenter&gt;
      &lt;/DockPanel&gt;
      &lt;/DataTemplate&gt;
      &lt;DataTemplate x:Key="WorkspacesTemplate"&gt;
          &lt;TabControl
        IsSynchronizedWithCurrentItem="True" 
        ItemsSource="{Binding}" 
        ItemTemplate="{StaticResource ClosableTabItemTemplate}"
        Margin="10"
        Background="#4C4C4C"/&gt;
      &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>My Menu and partial style listing</p>
  
  <p>//I  am not sure which value am I suppose to use, since I am not using header
  
      
   </p>
  
  <pre><code>&lt;Menu Background="Transparent"&gt;
      &lt;MenuItem Style="{StaticResource TabMenuButtonStyle}"
                          ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, 
                          AncestorType={x:Type TabControl}}, Path=Items}"
                          ItemContainerStyle="{StaticResource TabMenuItem}"&gt;
      &lt;/MenuItem&gt;
  &lt;/Menu&gt;
  </code></pre>