fix(dock): fix Element is already the child of another element exception

This commit is contained in:
2026-03-28 19:38:32 +09:00
parent de71043be3
commit 5845e7e9fb

View File

@@ -11,6 +11,7 @@ public sealed partial class DockLayout
{ {
if (GetTemplateChild(PART_ROOT_GRID) is Grid rootGrid) if (GetTemplateChild(PART_ROOT_GRID) is Grid rootGrid)
{ {
DisconnectUI(rootGrid);
rootGrid.Children.Clear(); rootGrid.Children.Clear();
if (Root != null) if (Root != null)
{ {
@@ -20,6 +21,21 @@ public sealed partial class DockLayout
} }
} }
private void DisconnectUI(UIElement element)
{
if (element is Ghost.Editor.Controls.NavigationTabView tabView)
{
tabView.TabItemsSource = null;
}
else if (element is Panel panel)
{
foreach (var child in panel.Children)
{
DisconnectUI(child);
}
}
}
private UIElement CreateUIForNode(DockNode node) private UIElement CreateUIForNode(DockNode node)
{ {
if (node is DockGroupNode groupNode) if (node is DockGroupNode groupNode)