private void collapseItem() { IOTabControl control = this.Parent as IOTabControl; this.Visibility = Visibility.Collapsed; var content = this.Content as UIElement; content.Visibility = Visibility.Collapsed; if (this.IsSelected) { control.SelectedIndex = -1; foreach (IOTabItem item in control.Items) { if (item.Visibility == Visibility.Visible) { control.SelectedItem = item; break; } } } var window = WinIOAPP.Current.MainWindow as WinIO.WPF.MainWindow; showIoMenuItem = window.CreatePanelMenuItem(this.Header, this); }
protected override void OnDrop(DragEventArgs e) { base.OnDrop(e); //检查数据是否包含制定字符串类型数据 if (e.Data.GetDataPresent("IOTabItem")) { //获取字符串 IOTabItem item = (IOTabItem)e.Data.GetData("IOTabItem"); IOTabControl parent = (IOTabControl)item.Parent; if (parent != this) { parent.Items.Remove(item); this.Items.Add(item); this.SelectedItem = item; item.TabPanelID = ((MainWindow)WinIOAPP.Instance.MainWindow).GetTabIndex(this); } else { // Point point = item.TranslatePoint(new Point(), parent); // 获得鼠标下面的控件 Point dragPoint = e.GetPosition(parent); IOTabItem hit = null; VisualTreeHelper.HitTest(parent, null, new HitTestResultCallback( (HitTestResult result) => { if (result.VisualHit is Border && result.VisualHit.GetValue(NameProperty).ToString() == "TabItemBorder") { hit = (result.VisualHit as Border).TemplatedParent as IOTabItem; return(HitTestResultBehavior.Stop); } return(HitTestResultBehavior.Continue); }), new PointHitTestParameters(dragPoint)); if (hit != null) { int insertIndex = parent.Items.IndexOf(hit); parent.Items.Remove(item); parent.Items.Insert(insertIndex, item); this.SelectedItem = item; } } } e.Handled = true; }