title: Show contents as per the selected tabitem in WPF
body: <p>I have an application named <strong>App Window</strong>. In which i need to display the installed apps in the tab items. Each tab item contains the data about its corresponding application. If a new app installed, then window will create a new tab item for the newly installed app.  </p>
  
  <p>*I have done upto creating a new tab item as per the installed applications.</p>
  
  <p><strong>Code i used:</strong></p>
  
  <pre><code>private List&lt;TabItem&gt; _tabItems; 
  private TabItem _tabAdd;
  
  try
  {
      _tabItems = new List&lt;TabItem&gt;();
  
      InstalledApps.DataContext = _tabItems;
  
      InstalledApps.SelectedIndex = 0;
  
      if (A Installed)
          this.AddTabItem("A");
  
      if (B Installed)
          this.AddTabItem("B");
  }
  catch (Exception ex)
  {
  }
  
  
  private TabItem AddTabItem(string AppName)
  {
  
      int count = 1;
  
      // create new tab item
      TabItem tab = new TabItem();
  
      tab.Header = AppName;
      string tabName = AppName.ToLower();
      tab.Name = tabName;
      tab.HeaderTemplate = InstalledApps.FindResource("TabHeader") as DataTemplate;
  
      TextBox txt = new TextBox();
      txt.IsReadOnly = true;
  
      tab.Content = txt;
  
      _tabItems.Insert(count - 1, tab);
  
      return tab;
  }
  </code></pre>
  
  <p><strong>Xaml:</strong> </p>
  
  <pre><code>&lt;TabControl Height="555" HorizontalAlignment="Left" Margin="0,-27,0,0" Name=" InstalledApps " ItemsSource="{Binding}" BorderThickness="0,0,0,0" SelectionChanged=" InstalledApps_SelectionChanged" VerticalAlignment="Top" Width="992" Grid.ColumnSpan="3" Grid.RowSpan="4"&gt;
      &lt;TabControl.Resources&gt;
          &lt;Style TargetType="TabItem"&gt;
              &lt;Setter Property="Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType="TabItem"&gt;
                          &lt;Grid Name="Panel"&gt;
                              &lt;ContentPresenter x:Name="ContentSite" VerticalAlignment="Center" 
                                HorizontalAlignment="Center" ContentSource="Header" Margin="80,10" /&gt;
                          &lt;/Grid&gt;
                          &lt;ControlTemplate.Triggers&gt;
                              &lt;Trigger Property="IsSelected" Value="True"&gt;
                                  &lt;Setter TargetName="Panel" Property="Background" Value="#FFEFEFEF" /&gt;
                              &lt;/Trigger&gt;
                              &lt;Trigger Property="IsSelected" Value="False"&gt;
                                  &lt;Setter TargetName="Panel" Property="Background" Value="#FFE0E0E0" /&gt;
                              &lt;/Trigger&gt;
                          &lt;/ControlTemplate.Triggers&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
              &lt;Style.Triggers&gt;
                  &lt;DataTrigger Binding="{Binding Items.Count, RelativeSource={RelativeSource Self}}" Value="0"&gt;
                      &lt;Setter Property="Visibility" Value="Hidden" /&gt;
                  &lt;/DataTrigger&gt;
              &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
          &lt;DataTemplate x:Key="TabHeader" DataType="TabItem"&gt;
              &lt;DockPanel&gt;
                  &lt;TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=TabItem }, Path=Header}" /&gt;
              &lt;/DockPanel&gt;
          &lt;/DataTemplate&gt;
  
      &lt;/TabControl.Resources&gt;
  &lt;/TabControl&gt;
  </code></pre>
  
  <p><strong>My requirement is:</strong>
  While i am selecting anyone tab from the listed tab items, then it should show its corresponding contents(logo, app name) in is content part.  </p>
  
  <p>Thanks in advance,
  Kathiresan S.</p>