From 0856e36b9defb61369b8c50019ae12749abfb1ca Mon Sep 17 00:00:00 2001 From: Dmitry Vodich Date: Wed, 7 Aug 2019 16:21:43 +0300 Subject: [PATCH 1/2] FixVisibilityBindings Fix visibility bindings of undocked panels in specific cases. --- .../LayoutAnchorableFloatingWindowControl.cs | 76 ++++++++++++++++++- .../Controls/LayoutAnchorableItem.cs | 11 +-- .../Controls/LayoutFloatingWindowControl.cs | 8 ++ .../Controls/LayoutGridControl.cs | 9 ++- .../Xceed.Wpf.AvalonDock/DockingManager.cs | 38 ++++++++-- 5 files changed, 123 insertions(+), 19 deletions(-) diff --git a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs index 9ad1a99e..3ffacc74 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs @@ -51,6 +51,7 @@ internal LayoutAnchorableFloatingWindowControl( LayoutAnchorableFloatingWindow m _model = model; HideWindowCommand = new RelayCommand( ( p ) => OnExecuteHideWindowCommand( p ), ( p ) => CanExecuteHideWindowCommand( p ) ); CloseWindowCommand = new RelayCommand( ( p ) => OnExecuteCloseWindowCommand( p ), ( p ) => CanExecuteCloseWindowCommand( p ) ); + Activated += LayoutAnchorableFloatingWindowControl_Activated; UpdateThemeResources(); MinWidth = _model.RootPanel.CalculatedDockMinWidth(); MinHeight = _model.RootPanel.CalculatedDockMinHeight(); @@ -71,6 +72,17 @@ private void OnRootUpdated(object sender, EventArgs e) } } + private void LayoutAnchorableFloatingWindowControl_Activated( object sender, EventArgs e ) + { + // Issue similar to: http://avalondock.codeplex.com/workitem/15036 + var visibilityBinding = GetBindingExpression( VisibilityProperty ); + + if ( visibilityBinding == null && Visibility == Visibility.Visible ) + { + SetVisibilityBinding(); + } + } + internal LayoutAnchorableFloatingWindowControl( LayoutAnchorableFloatingWindow model) : this( model, false ) { @@ -147,9 +159,9 @@ protected override void OnInitialized( EventArgs e ) IsVisibleChanged += ( s, args ) => { var visibilityBinding = GetBindingExpression( VisibilityProperty ); - if( IsVisible && ( visibilityBinding == null ) ) + if( visibilityBinding == null && IsVisible ) { - SetBinding( VisibilityProperty, new Binding( "IsVisible" ) { Source = _model, Converter = new BoolToVisibilityConverter(), Mode = BindingMode.OneWay, ConverterParameter = Visibility.Hidden } ); + SetVisibilityBinding(); } }; @@ -213,7 +225,12 @@ protected override IntPtr FilterMessage( IntPtr hwnd, int msg, IntPtr wParam, In case Win32Helper.WM_NCLBUTTONDOWN: //Left button down on title -> start dragging over docking manager if( wParam.ToInt32() == Win32Helper.HT_CAPTION ) { - _model.Descendents().OfType().First( p => p.ChildrenCount > 0 && p.SelectedContent != null ).SelectedContent.IsActive = true; + var anchorablePane = _model.Descendents().OfType() + .FirstOrDefault( p => p.ChildrenCount > 0 && p.SelectedContent != null ); + if( anchorablePane != null ) + { + anchorablePane.SelectedContent.IsActive = true; + } handled = true; } break; @@ -308,6 +325,59 @@ private bool IsContextMenuOpen() return false; } + private void SetVisibilityBinding() + { + SetBinding( + VisibilityProperty, + new Binding("IsVisible") + { + Source = _model, + Converter = new BoolToVisibilityConverter(), + Mode = BindingMode.OneWay, + ConverterParameter = Visibility.Hidden + } + ); + } + + #endregion + + #region Public Methods + + public override void EnableBindings() + { + _model.PropertyChanged += _model_PropertyChanged; + SetVisibilityBinding(); + var root = Model.Root; + if( root != null ) + { + LayoutRoot layoutRoot = root as LayoutRoot; + if ( layoutRoot != null ) + { + layoutRoot.Updated += OnRootUpdated; + } + } + + base.EnableBindings(); + } + + public override void DisableBindings() + { + var root = Model.Root; + if( root != null ) + { + LayoutRoot layoutRoot = root as LayoutRoot; + if( layoutRoot != null ) + { + layoutRoot.Updated -= OnRootUpdated; + } + } + + BindingOperations.ClearBinding( _model, VisibilityProperty ); + _model.PropertyChanged -= _model_PropertyChanged; + + base.DisableBindings(); + } + #endregion #region Commands diff --git a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableItem.cs b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableItem.cs index 62824834..e8bf609e 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableItem.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableItem.cs @@ -32,6 +32,7 @@ public class LayoutAnchorableItem : LayoutItem private ICommand _defaultAutoHideCommand; private ICommand _defaultDockCommand; private ReentrantFlag _visibilityReentrantFlag = new ReentrantFlag(); + private ReentrantFlag _anchorableVisibilityReentrantFlag = new ReentrantFlag(); #endregion @@ -377,9 +378,9 @@ private void _anchorable_IsVisibleChanged( object sender, EventArgs e ) { if( _anchorable != null && _anchorable.Root != null ) { - if( _visibilityReentrantFlag.CanEnter ) + if( _anchorableVisibilityReentrantFlag.CanEnter ) { - using( _visibilityReentrantFlag.Enter() ) + using( _anchorableVisibilityReentrantFlag.Enter() ) { if( _anchorable.IsVisible ) Visibility = Visibility.Visible; @@ -390,12 +391,6 @@ private void _anchorable_IsVisibleChanged( object sender, EventArgs e ) } } - - - - - - #endregion } } diff --git a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs index 844b1b9f..7b72a153 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs @@ -531,6 +531,14 @@ private void UpdateDragPosition() #endregion + public virtual void EnableBindings() + { + } + + public virtual void DisableBindings() + { + } + #region Internal Classes protected internal class FloatingWindowContentHost : HwndHost diff --git a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs index 962b5ab7..d00eecc0 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs @@ -641,12 +641,17 @@ private bool IsChildVisible(int index) { if( Orientation == Orientation.Horizontal ) { - return ColumnDefinitions[index].Width.IsStar || ColumnDefinitions[index].Width.Value > 0; + if ( index < ColumnDefinitions.Count ) + { + return ColumnDefinitions[ index ].Width.IsStar || ColumnDefinitions[ index ].Width.Value > 0; + } } - else + else if( index < RowDefinitions.Count ) { return RowDefinitions[ index ].Height.IsStar || RowDefinitions[ index ].Height.Value > 0; } + + return false; } private void ShowResizerOverlayWindow( LayoutGridResizerControl splitter ) diff --git a/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs b/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs index 097ccb6b..814a0126 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs @@ -43,6 +43,7 @@ public class DockingManager : Control, IOverlayWindowHost//, ILogicalChildrenCon private AutoHideWindowManager _autoHideWindowManager; private FrameworkElement _autohideArea; private List _fwList = new List(); + private List _fwHiddenList = new List(); private OverlayWindow _overlayWindow = null; private List _areas = null; private bool _insideInternalSetActiveContent = false; @@ -2378,6 +2379,19 @@ private void DockingManager_Loaded( object sender, RoutedEventArgs e ) SetupAutoHideWindow(); + foreach( var fwc in _fwHiddenList ) + { + fwc.EnableBindings(); + if( fwc.KeepContentVisibleOnClose ) + { + fwc.Show(); + fwc.KeepContentVisibleOnClose = false; + } + + _fwList.Add( fwc ); + } + _fwHiddenList.Clear(); + //load windows not already loaded! foreach( var fw in Layout.FloatingWindows.Where( fw => !_fwList.Any( fwc => fwc.Model == fw ) ) ) _fwList.Add( CreateUIElementForModel( fw ) as LayoutFloatingWindowControl ); @@ -2421,13 +2435,25 @@ private void DockingManager_Unloaded( object sender, RoutedEventArgs e ) foreach( var fw in _fwList.ToArray() ) { - //fw.Owner = null; - fw.SetParentWindowToNull(); - fw.KeepContentVisibleOnClose = true; - // To avoid calling Close method multiple times. - fw.InternalClose(true); + ////fw.Owner = null; + //fw.SetParentWindowToNull(); + //fw.KeepContentVisibleOnClose = true; + //// To avoid calling Close method multiple times. + //fw.InternalClose(true); + + // Unloaded can occure not only after closing of the application, but after switching between tabs. + // For such case it's better to hide the floating windows instead of closing it. + // We clear bindings on visibility during the owner is unloaded. + if( fw.IsVisible ) + { + fw.KeepContentVisibleOnClose = true; + fw.Hide(); + } + fw.DisableBindings(); + _fwHiddenList.Add( fw ); } - _fwList.Clear(); + + _fwList.Clear(); DestroyOverlayWindow(); FocusElementManager.FinalizeFocusManagement( this ); From bfed85e425f767962e70c42fbe306ca6d24fc6b0 Mon Sep 17 00:00:00 2001 From: Dmitry Vodich Date: Fri, 9 Aug 2019 18:06:51 +0300 Subject: [PATCH 2/2] Added unit tests --- .../DockingUtilitiesTest.cs | 111 ++++++++++++++++++ .../LayoutAnchorableTest.cs | 65 ++++++++++ .../Xceed.Wpf.AvalonDock.Test.csproj | 5 +- .../LayoutAnchorableFloatingWindowControl.cs | 4 +- .../Controls/LayoutFloatingWindowControl.cs | 4 +- .../Layout/LayoutAnchorable.cs | 2 +- 6 files changed, 186 insertions(+), 5 deletions(-) create mode 100644 source/AutomationTest/Xceed.Wpf.AvalonDock.Test/DockingUtilitiesTest.cs create mode 100644 source/AutomationTest/Xceed.Wpf.AvalonDock.Test/LayoutAnchorableTest.cs diff --git a/source/AutomationTest/Xceed.Wpf.AvalonDock.Test/DockingUtilitiesTest.cs b/source/AutomationTest/Xceed.Wpf.AvalonDock.Test/DockingUtilitiesTest.cs new file mode 100644 index 00000000..8fd92dc7 --- /dev/null +++ b/source/AutomationTest/Xceed.Wpf.AvalonDock.Test/DockingUtilitiesTest.cs @@ -0,0 +1,111 @@ +namespace Xceed.Wpf.AvalonDock.Test +{ + using System; + using System.Windows.Controls; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Xceed.Wpf.AvalonDock.Layout; + + [TestClass] + public sealed class DockingUtilitiesTest + { + [TestMethod] + public void CalculatedDockMinWidthHeightTest() + { + double defaultDockMinHeight = 25; + double defaultDockMinWidth = 25; + + const double documentPaneDockMinHeight = 200; + const double documentPaneDockMinWidth = 400; + LayoutDocumentPane layoutDocumentPane = new LayoutDocumentPane { DockMinHeight = documentPaneDockMinHeight, DockMinWidth = documentPaneDockMinWidth }; + layoutDocumentPane.InsertChildAt( 0, new LayoutDocument { ContentId = "Document" } ); + + LayoutDocumentPaneGroup layoutDocumentPaneGroup = new LayoutDocumentPaneGroup(); + layoutDocumentPaneGroup.InsertChildAt( 0, layoutDocumentPane ); + + const double anchorablePaneDockMinHeight = 80; + const double anchorablePaneDockMinWidth = 160; + LayoutAnchorablePane layoutAnchorablePane = new LayoutAnchorablePane { DockMinHeight = anchorablePaneDockMinHeight, DockMinWidth = anchorablePaneDockMinWidth }; + layoutAnchorablePane.InsertChildAt( 0, new LayoutAnchorable { ContentId = "Anchorable" } ); + + LayoutAnchorablePaneGroup layoutAnchorablePaneGroup = new LayoutAnchorablePaneGroup(); + layoutAnchorablePaneGroup.InsertChildAt( 0, layoutAnchorablePane ); + + LayoutPanel layoutPanel = new LayoutPanel(); + layoutPanel.InsertChildAt( 0, layoutDocumentPaneGroup ); + layoutPanel.InsertChildAt( 1, layoutAnchorablePaneGroup ); + + Assert.AreEqual( defaultDockMinWidth, layoutPanel.DockMinWidth ); + Assert.AreEqual( defaultDockMinHeight, layoutPanel.DockMinHeight ); + Assert.AreEqual( documentPaneDockMinWidth + anchorablePaneDockMinWidth, layoutPanel.CalculatedDockMinWidth() ); + Assert.AreEqual( Math.Max(documentPaneDockMinHeight, anchorablePaneDockMinHeight), layoutPanel.CalculatedDockMinHeight() ); + + Assert.AreEqual( documentPaneDockMinWidth, layoutDocumentPane.DockMinWidth ); + Assert.AreEqual( documentPaneDockMinHeight, layoutDocumentPane.DockMinHeight ); + Assert.AreEqual( layoutDocumentPane.DockMinWidth, layoutDocumentPane.CalculatedDockMinWidth() ); + Assert.AreEqual( layoutDocumentPane.DockMinHeight, layoutDocumentPane.CalculatedDockMinHeight() ); + + Assert.AreEqual( defaultDockMinWidth, layoutDocumentPaneGroup.DockMinWidth ); + Assert.AreEqual( defaultDockMinWidth, layoutDocumentPaneGroup.DockMinHeight ); + Assert.AreEqual( documentPaneDockMinWidth, layoutDocumentPaneGroup.CalculatedDockMinWidth() ); + Assert.AreEqual( documentPaneDockMinHeight, layoutDocumentPaneGroup.CalculatedDockMinHeight() ); + + Assert.AreEqual( anchorablePaneDockMinWidth, layoutAnchorablePane.DockMinWidth ); + Assert.AreEqual( anchorablePaneDockMinHeight, layoutAnchorablePane.DockMinHeight ); + Assert.AreEqual( layoutAnchorablePane.DockMinWidth, layoutAnchorablePane.CalculatedDockMinWidth() ); + Assert.AreEqual( layoutAnchorablePane.DockMinHeight, layoutAnchorablePane.CalculatedDockMinHeight() ); + + Assert.AreEqual( defaultDockMinWidth, layoutAnchorablePaneGroup.DockMinWidth ); + Assert.AreEqual( defaultDockMinWidth, layoutAnchorablePaneGroup.DockMinHeight ); + Assert.AreEqual( anchorablePaneDockMinWidth, layoutAnchorablePaneGroup.CalculatedDockMinWidth() ); + Assert.AreEqual( anchorablePaneDockMinHeight, layoutAnchorablePaneGroup.CalculatedDockMinHeight() ); + + layoutPanel.RemoveChild( layoutDocumentPaneGroup ); + Assert.AreEqual( anchorablePaneDockMinWidth, layoutPanel.CalculatedDockMinWidth() ); + Assert.AreEqual( anchorablePaneDockMinHeight, layoutPanel.CalculatedDockMinHeight() ); + } + + [TestMethod] + public void UpdateDocMinWidthHeightTest() + { + double documentPaneDockMinHeight = 100; + double documentPaneDockMinWidth = 101; + LayoutDocumentPane layoutDocumentPane = new LayoutDocumentPane { DockMinHeight = documentPaneDockMinHeight, DockMinWidth = documentPaneDockMinWidth }; + layoutDocumentPane.InsertChildAt( 0, new LayoutDocument { ContentId = "Document" } ); + + LayoutDocumentPaneGroup layoutDocumentPaneGroup = new LayoutDocumentPaneGroup(); + layoutDocumentPaneGroup.InsertChildAt( 0, layoutDocumentPane ); + + double anchorablePane1DockMinHeight = 150; + double anchorablePane1DockMinWidth = 151; + LayoutAnchorablePane layoutAnchorablePane1 = new LayoutAnchorablePane { DockMinHeight = anchorablePane1DockMinHeight, DockMinWidth = anchorablePane1DockMinWidth }; + layoutAnchorablePane1.InsertChildAt( 0, new LayoutAnchorable { ContentId = "Anchorable1" } ); + + double anchorablePane2DockMinHeight = 200; + double anchorablePane2DockMinWidth = 201; + LayoutAnchorablePane layoutAnchorablePane2 = new LayoutAnchorablePane { DockMinHeight = anchorablePane2DockMinHeight, DockMinWidth = anchorablePane2DockMinWidth }; + layoutAnchorablePane2.InsertChildAt( 0, new LayoutAnchorable { ContentId = "Anchorable2" } ); + + LayoutAnchorablePaneGroup layoutAnchorablePaneGroup = new LayoutAnchorablePaneGroup { Orientation = Orientation.Horizontal }; + layoutAnchorablePaneGroup.InsertChildAt( 0, layoutAnchorablePane1 ); + layoutAnchorablePaneGroup.InsertChildAt( 0, layoutAnchorablePane2 ); + + LayoutPanel layoutPanel = new LayoutPanel { Orientation = Orientation.Vertical }; + layoutPanel.InsertChildAt( 0, layoutDocumentPaneGroup ); + layoutPanel.InsertChildAt( 1, layoutAnchorablePaneGroup ); + + Assert.AreEqual( anchorablePane2DockMinWidth + anchorablePane1DockMinWidth, layoutAnchorablePaneGroup.CalculatedDockMinWidth() ); + Assert.AreEqual( Math.Max( anchorablePane2DockMinHeight, anchorablePane1DockMinHeight ), layoutAnchorablePaneGroup.CalculatedDockMinHeight() ); + + Assert.AreEqual( documentPaneDockMinWidth, layoutDocumentPaneGroup.CalculatedDockMinWidth() ); + Assert.AreEqual( documentPaneDockMinHeight, layoutDocumentPaneGroup.CalculatedDockMinHeight() ); + + Assert.AreEqual( + Math.Max( anchorablePane1DockMinWidth + anchorablePane2DockMinWidth, documentPaneDockMinWidth ), + layoutPanel.CalculatedDockMinWidth() ); + + Assert.AreEqual( documentPaneDockMinHeight + anchorablePane2DockMinHeight, layoutPanel.CalculatedDockMinHeight() ); + } + } +} diff --git a/source/AutomationTest/Xceed.Wpf.AvalonDock.Test/LayoutAnchorableTest.cs b/source/AutomationTest/Xceed.Wpf.AvalonDock.Test/LayoutAnchorableTest.cs new file mode 100644 index 00000000..e6e3b34e --- /dev/null +++ b/source/AutomationTest/Xceed.Wpf.AvalonDock.Test/LayoutAnchorableTest.cs @@ -0,0 +1,65 @@ +using System.Linq; +using System.Reflection; +using System.Windows; +using System.Windows.Data; + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Xceed.Wpf.AvalonDock.Controls; +using Xceed.Wpf.AvalonDock.Converters; +using Xceed.Wpf.AvalonDock.Layout; + +namespace Xceed.Wpf.AvalonDock.Test +{ + [TestClass] + public sealed class LayoutAnchorableTest + { + [TestMethod] + public void ClearBindingOfHiddenWindowTest() + { + LayoutAnchorable layoutAnchorable = new LayoutAnchorable + { + FloatingWidth = 50, + FloatingHeight = 100, + ContentId = "Test" + }; + + LayoutAnchorablePane layoutAnchorablePane = new LayoutAnchorablePane( layoutAnchorable ); + LayoutAnchorablePaneGroup layoutAnchorablePaneGroup = new LayoutAnchorablePaneGroup( layoutAnchorablePane ); + LayoutAnchorableFloatingWindow layoutFloatingWindow = new LayoutAnchorableFloatingWindow + { + RootPanel = layoutAnchorablePaneGroup + }; + + var ctor = typeof( LayoutAnchorableFloatingWindowControl ) + .GetTypeInfo() + .GetConstructors( BindingFlags.NonPublic | BindingFlags.Instance ) + .First( x => x.GetParameters().Length == 1 ); + + LayoutAnchorableFloatingWindowControl floatingWindowControl = ctor.Invoke( new object[] {layoutFloatingWindow} ) as LayoutAnchorableFloatingWindowControl; + floatingWindowControl.SetBinding( + UIElement.VisibilityProperty, + new Binding( "IsVisible" ) + { + Source = floatingWindowControl.Model, + Converter = new BoolToVisibilityConverter(), + Mode = BindingMode.OneWay, + ConverterParameter = Visibility.Hidden + } ); + + BindingExpression visibilityBinding = floatingWindowControl.GetBindingExpression( UIElement.VisibilityProperty ); + Assert.IsNotNull( visibilityBinding ); + + layoutAnchorable.Show(); + layoutAnchorable.Hide(); + + visibilityBinding = floatingWindowControl.GetBindingExpression( UIElement.VisibilityProperty ); + Assert.IsNotNull( visibilityBinding ); + + floatingWindowControl.Hide(); + + visibilityBinding = floatingWindowControl.GetBindingExpression( UIElement.VisibilityProperty ); + Assert.IsNull( visibilityBinding ); + } + } +} diff --git a/source/AutomationTest/Xceed.Wpf.AvalonDock.Test/Xceed.Wpf.AvalonDock.Test.csproj b/source/AutomationTest/Xceed.Wpf.AvalonDock.Test/Xceed.Wpf.AvalonDock.Test.csproj index 82a80bae..3a7d19b1 100644 --- a/source/AutomationTest/Xceed.Wpf.AvalonDock.Test/Xceed.Wpf.AvalonDock.Test.csproj +++ b/source/AutomationTest/Xceed.Wpf.AvalonDock.Test/Xceed.Wpf.AvalonDock.Test.csproj @@ -52,10 +52,13 @@ + + + TestApp.xaml @@ -102,4 +105,4 @@ - + \ No newline at end of file diff --git a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs index 3ffacc74..0c363a57 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs @@ -201,6 +201,8 @@ protected override void OnClosed( EventArgs e ) BindingOperations.ClearBinding(_model, VisibilityProperty); _model.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler( _model_PropertyChanged ); + + Activated -= LayoutAnchorableFloatingWindowControl_Activated; } protected override void OnClosing( System.ComponentModel.CancelEventArgs e ) @@ -329,7 +331,7 @@ private void SetVisibilityBinding() { SetBinding( VisibilityProperty, - new Binding("IsVisible") + new Binding( "IsVisible" ) { Source = _model, Converter = new BoolToVisibilityConverter(), diff --git a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs index 7b72a153..b2bb064c 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs @@ -310,8 +310,8 @@ internal virtual void UpdateThemeResources( Theme oldTheme = null ) } } - var manager = _model.Root.Manager; - if( manager.Theme != null ) + var manager = _model.Root?.Manager; + if( manager?.Theme != null ) { if( manager.Theme is DictionaryTheme ) { diff --git a/source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorable.cs b/source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorable.cs index 5bbe0a1c..9a41987e 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorable.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorable.cs @@ -419,7 +419,7 @@ public void Hide( bool cancelable = true ) PreviousContainer = parentAsGroup; PreviousContainerIndex = parentAsGroup.IndexOfChild( this ); } - Root.Hidden.Add( this ); + Root?.Hidden?.Add( this ); RaisePropertyChanged( "IsVisible" ); RaisePropertyChanged( "IsHidden" ); NotifyIsVisibleChanged();