title: How to bind to Tabcontrol.Items
body: <p>I have a WPF application that I'm trying to dynamically add items to a tabcontrol.  I have a list of menu items that should be databound to the tabcontrol's items.  The only problem is that TabControl.Items does not notify others that items have been added.  I've tested this by binding instead to TabControl.Items.Count and get calls to the converter (but the value passed in is the count and not something useful).  Here's the relevent code that doesn't get databound properly because Items doesn't call out updates:</p>
  
  <pre><code>&lt;MenuItem ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=Items, Converter={StaticResource TabControlItemConverter}}"&gt;
  </code></pre>
  
  <p>This MenuItem XAML is inside a ControlTemplate for a TabControl.  With static items, i.e., items that are already defined in a TabControl, this code works perfectly.  But I have a TabControl that gets items added at runtime and can't seem to update this binding.  Has anyone added some sort of attached property to a TabControl that can bind to the Items collection?  </p>
  
  <p><strong>Edit for background info</strong>
  The TabControl that has items added to it is a region (this is a Prism application).  Here is the relevent XAML</p>
  
  <pre><code>&lt;TabControl cal:RegionManager.RegionName="{x:Static local:LocalRegionNames.SelectedItemRegion}" &gt;
              &lt;TabControl.Resources&gt;
                  &lt;Style TargetType="TabItem" BasedOn="{StaticResource TabItemStyle}"&gt;
                      &lt;Setter Property="HeaderTemplate"&gt;
                          &lt;Setter.Value&gt;
                              &lt;DataTemplate&gt;
                                  &lt;StackPanel Orientation="Horizontal"&gt;
                                      &lt;Image Style="{StaticResource tabItemImage}" Height="20" /&gt;
                                      &lt;TextBlock Text="{Binding Content.DataContext.TabHeader, RelativeSource={RelativeSource AncestorType=TabItem}}" VerticalAlignment="Center" /&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/Setter.Value&gt;
                      &lt;/Setter&gt;
                  &lt;/Style&gt;
              &lt;/TabControl.Resources&gt;
          &lt;/TabControl&gt;
  </code></pre>
  
  <p>The relevent code for adding a view to the region is here:</p>
  
  <pre><code>ProjectDetailView view = new ProjectDetailView();
  ProjectDetailViewModel viewModel = new ProjectDetailViewModel();
  viewModel.CurrentProject = project;
  view.DataContext = viewModel;
  
  
  
   IRegionManager retManager = RegionManager.Regions[LocalRegionNames.SelectedItemRegion].Add(view, null, true);
     RegionManager.Regions[LocalRegionNames.SelectedItemRegion].Activate(view);
  </code></pre>
  
  <p>All this works fine...views get added, the tab control adds items, and views appear.  But the Items property on the tabcontrol never broadcasts the changes to its collection.  </p>