Esempio n. 1
0
        private static void CloseTabCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ShellView shellView = (ShellView)sender;

            shellView.CloseTab(shellView.TabControl.ItemContainerGenerator.IndexFromContainer((DependencyObject)e.Parameter));
            if (shellView.TabControl.Items.Count == 0)
            {
                shellView.Close();
            }
        }
        void ITabTearOffHandler.HandleTargetedDrop(object item, TabControl sourceTabControl, int sourceIndex, TabControl targetTabControl, int insertionIndex)
        {
            ShellView sourceWindow = Window.GetWindow(sourceTabControl) as ShellView;

            if (sourceWindow == null)
            {
                return;
            }
            using (sourceWindow.CreateIgnoreSelectionChangedScope())
            {
                sourceTabControl.Items.RemoveAt(sourceIndex);
            }
            targetTabControl.Items.Insert(insertionIndex, item);
            targetTabControl.SelectedIndex = insertionIndex;
            if (sourceTabControl.Items.Count != 0)
            {
                return;
            }
            sourceWindow.Close();
            this._shellViewFactory.Release(sourceWindow);
        }