private bool TryDockToWindow(HostWindow window, Point position, TabViewModelBase tab) { if (!(window.TabControl.InputHitTest(position) is FrameworkElement element)) { return(false); } // Test if the mouse is over the tab panel or a tab item. if (!CanInsertTabItem(element)) { return(false); } tab.PrepareToWindowTransfer(); var sourceHost = (HostWindowViewModel)DataContext; var targetHost = (HostWindowViewModel)window.DataContext; sourceHost.DetachTab(tab); targetHost.AttachTab(tab); window.BringToFront(); //We run this method on the tab control for it to grab the tab and position it at the mouse, ready to move again. window.TabControl.GrabTab(tab); return(true); }
private bool TryDragTabToWindow(Point position, TabViewModelBase tab) { if (tab.IsPinned) { return(false); } var win = new HostWindow(tab) { Width = Width, Height = Height, Left = Left, Top = position.Y - TabControl.TabPanelHeight / 2 }; win.Show(); return(true); }