ClosableTabItem TurnWindowToTab(ImagePopUp window) { ClosableTabItem newTab = new ClosableTabItem(); try { ScrollViewer sv = ((ScrollViewer)((Grid)window.ActualContent).Children[0]); ((Grid)window.ActualContent).Children.Remove(sv); window.Close(); newTab.Content = sv; } catch { } return newTab; }
Window TurnTabToAWindow(ClosableTabItem tabItem) { ImagePopUp window = new ImagePopUp(); try { window.WindowTitle.Text = tabItem.Title; ScrollViewer sv = ((ScrollViewer)tabItem.Content); tabItem.Content = null; window.ActualContent.Children.Add(sv); window.Owner = this; window.MouseDoubleClick += new MouseButtonEventHandler(window_MouseDoubleClick); ((System.Windows.Controls.TabControl)tabItem.Parent).Items.Remove(tabItem); } catch { } return window; }