From 5a039542851d88b2c5128f69403fac02540199b0 Mon Sep 17 00:00:00 2001 From: Buchfink Date: Tue, 1 Mar 2022 14:25:45 +0100 Subject: [PATCH] Keep ActiveContent when switching RootPanel --- source/Components/AvalonDock/Layout/LayoutRoot.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/Components/AvalonDock/Layout/LayoutRoot.cs b/source/Components/AvalonDock/Layout/LayoutRoot.cs index 73fe1b4a..ba81f75c 100644 --- a/source/Components/AvalonDock/Layout/LayoutRoot.cs +++ b/source/Components/AvalonDock/Layout/LayoutRoot.cs @@ -98,9 +98,19 @@ public LayoutPanel RootPanel { if (_rootPanel == value) return; RaisePropertyChanging(nameof(RootPanel)); + var activeContent = ActiveContent; + var activeRoot = activeContent?.Root; if (_rootPanel != null && _rootPanel.Parent == this) _rootPanel.Parent = null; _rootPanel = value ?? new LayoutPanel(new LayoutDocumentPane()); _rootPanel.Parent = this; + if (ActiveContent == null && activeRoot == this && activeContent != null) + { + ActiveContent = activeContent; + if (ActiveContent != activeContent) + { + ActiveContent = activeContent; + } + } RaisePropertyChanged(nameof(RootPanel)); } }