title: Doubleclick the TabItem in Tab Control and View pops up as floating Window
body: <p>I have a tab control in my mainwindow.xaml file. On startup, when the app runs, all four tabs are shown. Is there a way that once a user double clicks the 'Connect' tab, the entire view of this tab pops up as a new floating window and if I doubleclick the popped up window, it goes back to the initial state?</p>
  
  <pre><code>&lt;Grid Grid.Row="0" &gt;
         &lt;TabControl Name="ConnectTab" Style="{DynamicResource styleBackground}" /&gt;                          
                 &lt;tablocal:CloseableTabItem Header="Connect" /&gt;
                 &lt;tablocal:CloseableTabItem Header="I2C" /&gt;
                 &lt;tablocal:CloseableTabItem Header="Voltage" /&gt;
                 &lt;tablocal:CloseableTabItem Header="Clock" /&gt;
         &lt;/TabControl&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p><strong>This is my closebutton method for Tab:</strong></p>
  
  <pre><code> private void CloseTab(object source, RoutedEventArgs args)
      {            
          TabItem tabItem = args.Source as TabItem;
  
          if (ConnectTab != null &amp;&amp; ConnectTab.Items.Count &gt; 1)
              ConnectTab.Items.Remove(tabItem);                     
      }
  </code></pre>
  
  <p><strong>Closetab class:</strong>   </p>
  
  <pre><code>public class CloseableTabItem : TabItem
  {
      static CloseableTabItem()
      {
          //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
          //This style is defined in themes\generic.xaml
          DefaultStyleKeyProperty.OverrideMetadata(typeof(CloseableTabItem),
              new FrameworkPropertyMetadata(typeof(CloseableTabItem)));
      }
  
      public static readonly RoutedEvent CloseTabEvent =
          EventManager.RegisterRoutedEvent("CloseTab", RoutingStrategy.Bubble,
              typeof(RoutedEventHandler), typeof(CloseableTabItem));
  
      public event RoutedEventHandler CloseTab
      {
          add { AddHandler(CloseTabEvent, value); }
          remove { RemoveHandler(CloseTabEvent, value); }
      }
  
      public override void OnApplyTemplate()
      {
          base.OnApplyTemplate();
  
          Button closeButton = base.GetTemplateChild("PART_Close") as Button;
          if (closeButton != null)
              closeButton.Click += new System.Windows.RoutedEventHandler(closeButton_Click);
      }
  
      void closeButton_Click(object sender, System.Windows.RoutedEventArgs e)
      {
          this.RaiseEvent(new RoutedEventArgs(CloseTabEvent, this));
      }
  }
  </code></pre>