diff --git a/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.cs b/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.cs index 5e693ea..40d219e 100644 --- a/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.cs +++ b/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.cs @@ -40,6 +40,7 @@ public partial class DockGroup : DockContainer _tabView.DragOver -= OnDragOver; _tabView.Drop -= OnDrop; _tabView.DragLeave -= OnDragLeave; + _tabView.TabCloseRequested -= OnTabCloseRequested; } _tabView = GetTemplateChild(PART_TAB_VIEW) as TabView; @@ -51,6 +52,7 @@ public partial class DockGroup : DockContainer _tabView.DragOver += OnDragOver; _tabView.Drop += OnDrop; _tabView.DragLeave += OnDragLeave; + _tabView.TabCloseRequested += OnTabCloseRequested; } UpdateTabs(); @@ -94,6 +96,14 @@ public partial class DockGroup : DockContainer Root?.HideHighlight(); } + private void OnTabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args) + { + if (args.Tab.Tag is DockDocument doc) + { + RemoveChild(doc); + } + } + protected override void OnChildrenUpdated() { UpdateTabs(); diff --git a/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml b/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml index f4b0f0b..208fc00 100644 --- a/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml +++ b/src/Editor/Ghost.Editor/View/Controls/Docking/DockGroup.xaml @@ -10,7 +10,7 @@ diff --git a/src/Editor/Ghost.Editor/View/Controls/Docking/DockingLayout.cs b/src/Editor/Ghost.Editor/View/Controls/Docking/DockingLayout.cs index fabaca1..710e9a0 100644 --- a/src/Editor/Ghost.Editor/View/Controls/Docking/DockingLayout.cs +++ b/src/Editor/Ghost.Editor/View/Controls/Docking/DockingLayout.cs @@ -116,6 +116,7 @@ public class DockingLayout : Control private void SplitGroup(DockGroup targetGroup, DockDocument doc, DockTarget target) { + doc.Owner?.RemoveChild(doc); var parentPanel = targetGroup.Owner as DockPanel; if (parentPanel == null)