Index: Core/Gui/src/Core.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs =================================================================== diff -u -r66c330d0a99ef95f30fe34b40700bd86d296862b -rf35f6e21cc9ffd9ac8d0db3cdddf7240f0158361 --- Core/Gui/src/Core.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs (.../AvalonDockViewHost.xaml.cs) (revision 66c330d0a99ef95f30fe34b40700bd86d296862b) +++ Core/Gui/src/Core.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs (.../AvalonDockViewHost.xaml.cs) (revision f35f6e21cc9ffd9ac8d0db3cdddf7240f0158361) @@ -189,6 +189,7 @@ PerformWithoutChangingActiveContent(() => { layoutDocument.Close(); + UpdateDockingManager(); }); if (ReferenceEquals(ActiveDocumentView, view)) @@ -203,6 +204,7 @@ PerformWithoutChangingActiveContent(() => { layoutAnchorable.Hide(); + UpdateDockingManager(); }); } } @@ -274,7 +276,7 @@ { layoutContent.IsActive = true; - DockingManager.UpdateLayout(); // This method is called in order to get rid of problems caused by AvalonDock's latency + UpdateDockingManager(); } }); } @@ -389,13 +391,12 @@ toolViews.Remove(view); } - view.Data = null; - CleanupHostControl(view); - OnViewClosed(view); + view.Data = null; + view.Dispose(); - Application.DoEvents(); // This method is called in order to get rid of problems caused by AvalonDock's latency + OnViewClosed(view); } private void PerformWithoutChangingActiveContent(Action actionToPerform) @@ -409,10 +410,19 @@ DockingManager.ActiveContentChanged += OnActiveContentChanged; } + /// + /// This method can be called in order to get rid of problems caused by AvalonDock's latency. + /// + private void UpdateDockingManager() + { + DockingManager.UpdateLayout(); + } + private void CleanupHostControl(IView view) { WindowsFormsHost hostControl = hostControls.First(hc => hc.Child == view); + hostControl.Child = null; // Prevent views from getting disposed here by clearing the child hostControl.Dispose(); hostControls.Remove(hostControl);