title: Programmatically add new Datagrid (or other UserControll) into a programmatically generated TabItem (using mvvm)
body: <p>I have an XAML-Code with an TabControl that contains 2 tabs (Tab A and Tab B). In Tab A I can make configurations for Tab B, Tab B can therefore change dynamically in dependency to Tab A. Tab B contains a static Tabcontroll without any tabs implemented (beqause tabs will be generated later). Notice: "Tab A" and "Tab B" are the Master Tabs, "Tab C", "Tab D", and so on are the child Tabs from "Tab B".</p>
  
  <p>This is My XAML Code:</p>
  
  <pre><code>&lt;TabItem Header="TAB_B"&gt;
              &lt;Grid&gt;
                  &lt;TabControl ItemsSource="{Binding MyTabItems, UpdateSourceTrigger=PropertyChanged}"&gt;
                          &lt;TabControl.ItemTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;!-- here I want to show a Datagrid for each new Tab ("Tab C", "Tab D", ...) --&gt;
                              &lt;/DataTemplate&gt;                            
                          &lt;/TabControl.ItemTemplate&gt;
                  &lt;/TabControl&gt;
              &lt;/Grid&gt;
          &lt;/TabItem&gt;
  </code></pre>
  
  <p>In my ViewModel I have the binding property:</p>
  
  <pre><code>    private ObservableCollection&lt;TabItem&gt; _myTabItems;
      public ObservableCollection&lt;TabItem&gt; MyTabItems
      {
          get { return _myTabItems; }
          set
          {
              _myTabItems = value;
              OnPropertyChanged("MyTabItems");
          }
      }
  </code></pre>
  
  <p>In my Viewmodel a have a method that builds my Tab Items in the TabController in Tab B:</p>
  
  <pre><code>    public void BuildContentOfTabB()
      {
          foreach (var item in myTabList)
          {
                  MyTab = new TabItem();
                  MyTab.Header = myHeaderString; // e.g. "Tab C", "Tab D"
                  MyTabItems.Add(MyTab);
              }
          }
      }
  </code></pre>
  
  <p>This works well. I get new TabItems ("Tab C", "Tab D",...) in my TabController. Now I want to get new UserControlls like a Datagrid in "Tab C" or "Tab D". I don't have any idea how to solve my problem. Thank you for answering.</p>