void MoveDraggedItemToNewControl(MouseButtonEventArgs e) { bool ctrlDown = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl); if (ctrlDown || this.controlUnderCursor == null || this.hitTestSpot == null) { var pos = draggedItem.PointToScreenIndependent(e.GetPosition(draggedItem)); var originalContent = draggedItem.Content as FrameworkElement; Size size = new Size(300, 200); if (originalContent != null) { size = new Size(originalContent.ActualWidth, originalContent.ActualHeight); } var w = sourceSplitTabsControl.CreateFloatingHost(); w.Left = pos.X; w.Top = pos.Y; w.Width = size.Width; w.Height = size.Height; w.SplitTabsControl.Loaded += (s, e2) => { sourceSplitTabsControl.RemoveItemFromControl(this.draggedItem); w.SplitTabsControl.AddItemToControl(this.draggedItem, w.SplitTabsControl.RootNode.TabControl, true); }; w.Show(); return; } SplitTabsControl destSplitTabsControl = this.controlUnderCursor.FindParent <SplitTabsControl>(); if (sourceSplitTabsControl == null || destSplitTabsControl == null) { Debug.Fail("How does a tab control not live in a split tabs control parent?"); return; } // Before removing the dragged item (which presumably has focus), set focus on the destination // tab control. Otherwise we end up removing the focused element from the tree, which tends to // confuse the WPF focus manager. destSplitTabsControl.Focus(); if (this.hitTestSpot.IsTabbed) { if (this.controlUnderCursor != this.sourceControl) { sourceSplitTabsControl.RemoveItemFromControl(this.draggedItem); destSplitTabsControl.AddItemToControl(this.draggedItem, this.controlUnderCursor, true); } return; } var newNode = destSplitTabsControl.SplitNode(this.hitTestSpot.DestinationNode, this.hitTestSpot.Dock); if (newNode != null) { sourceSplitTabsControl.RemoveItemFromControl(this.draggedItem); destSplitTabsControl.AddItemToControl(this.draggedItem, newNode.TabControl, true); } }