fix(dock): fix Element is already the child of another element exception
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user