title: How to close Tab with a close button in WPF?
body: <p>I am working on a WPF app where it creates new tab upon clicking a button. That is working fine. I am having hard time in figuring out how to have a close button, like a <strong>X</strong> next to the Tab header and close the selected tab? </p>
  
  <p><strong>MainWindow.xaml</strong></p>
  
  <pre><code>&lt;Grid&gt;
          &lt;StackPanel Name="listConnections" Grid.Column="0" Background="#4682b4" Margin="0,0,0,-0.2" &gt;
          &lt;/StackPanel&gt;            
          &lt;TabControl Name="tabConnections" Grid.Column="1" TabStripPlacement="Top" Margin="0,0,0.4,-0.2"&gt;
          &lt;/TabControl&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>add Tab method to create new tabs upon button click <strong>MainWindow.xaml.cs</strong></p>
  
  <pre><code>public void addTab(Connection connection)
  {
      TabItem tab = new TabItem();
      tab.Header = connection.name;
      tabConnections.Items.Add(tab);
  }
  </code></pre>
  
  <p>Is there a simple way to do the close button? </p>