diff --git a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs index ef15595a..246de59e 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs @@ -324,6 +324,8 @@ private void OnExecuteHideWindowCommand( object parameter ) var anchorableLayoutItem = manager.GetLayoutItemFromModel( anchorable ) as LayoutAnchorableItem; anchorableLayoutItem.HideCommand.Execute( parameter ); } + + Hide(); // Bring toolwindows inside hidden FloatingWindow back requires restart of app } #endregion diff --git a/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs b/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs index 289e25da..dab25ed3 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs @@ -2069,16 +2069,18 @@ internal UIElement CreateUIElementForModel( ILayoutElement model ) }; newFW.SetParentToMainWindowOf( this ); - var paneForExtensions = modelFW.RootPanel.Children.OfType().FirstOrDefault(); - if( paneForExtensions != null ) + // Floating Window can also contain only Pane Groups at its base (issue #27) so we check for + // RootPanel (which is a LayoutAnchorablePaneGroup) and make sure the window is positioned back + // in current (or nearest) monitor + var panegroup = modelFW.RootPanel; + if (panegroup != null) { - //ensure that floating window position is inside current (or nearest) monitor - paneForExtensions.KeepInsideNearestMonitor(); + panegroup.KeepInsideNearestMonitor(); // Check position is valid in current setup - newFW.Left = paneForExtensions.FloatingLeft; - newFW.Top = paneForExtensions.FloatingTop; - newFW.Width = paneForExtensions.FloatingWidth; - newFW.Height = paneForExtensions.FloatingHeight; + newFW.Left = panegroup.FloatingLeft; // Position the window to previous or nearest valid position + newFW.Top = panegroup.FloatingTop; + newFW.Width = panegroup.FloatingWidth; + newFW.Height = panegroup.FloatingHeight; } newFW.ShowInTaskbar = false; @@ -2088,11 +2090,11 @@ internal UIElement CreateUIElementForModel( ILayoutElement model ) newFW.Show(); } ), DispatcherPriority.Send ); - // Do not set the WindowState before showing or it will be lost - if( paneForExtensions != null && paneForExtensions.IsMaximized ) + if( panegroup != null && panegroup.IsMaximized ) { newFW.WindowState = WindowState.Maximized; } + return newFW; } diff --git a/source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorable.cs b/source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorable.cs index c07ffd9f..29b8e0f4 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorable.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorable.cs @@ -765,6 +765,14 @@ private void NotifyIsVisibleChanged() private void UpdateParentVisibility() { + // Element is Hidden since it has no parent but a previous parent + if (this.PreviousContainer != null && Parent == null) + { + // Go back to using previous parent + Parent = PreviousContainer; +//// PreviousContainer = null; + } + var parentPane = Parent as ILayoutElementWithVisibility; if( parentPane != null ) parentPane.ComputeVisibility(); diff --git a/source/MLibTest/MLibTest/Demos/PanesTemplateSelector.cs b/source/MLibTest/MLibTest/Demos/PanesTemplateSelector.cs index ddfe94bc..f5bed864 100644 --- a/source/MLibTest/MLibTest/Demos/PanesTemplateSelector.cs +++ b/source/MLibTest/MLibTest/Demos/PanesTemplateSelector.cs @@ -36,6 +36,8 @@ public PanesTemplateSelector() /// public DataTemplate ColorPickerViewTemplate { get; set; } + public DataTemplate Tooln_ViewTemplate { get; set; } + /// /// Gets a template for simple testing tool windows. /// diff --git a/source/MLibTest/MLibTest/Demos/ViewModels/WorkSpaceViewModel.cs b/source/MLibTest/MLibTest/Demos/ViewModels/WorkSpaceViewModel.cs index 9f0d8575..3a216af8 100644 --- a/source/MLibTest/MLibTest/Demos/ViewModels/WorkSpaceViewModel.cs +++ b/source/MLibTest/MLibTest/Demos/ViewModels/WorkSpaceViewModel.cs @@ -106,6 +106,9 @@ internal class WorkSpaceViewModel : MLibTest.ViewModels.Base.ViewModelBase, IWor private Tool3_ViewModel _Tool3; private FileViewModel _activeDocument = null; + private Tool1_ViewModel _Tool1; + private Tool2_ViewModel _Tool2; + private Tool3_ViewModel _Tool3; #endregion private fields #region constructors @@ -167,7 +170,8 @@ public IEnumerable Tools get { if (_tools == null) - _tools = new ToolViewModel[] { FileStats, ColorPicker, Tool1, Tool2, Tool3 }; + _tools = new ToolViewModel[] { FileStats, ColorPicker, _Tool1, _Tool2, _Tool3 }; + return _tools; } } diff --git a/source/MLibTest/MLibTest/MLibTest.csproj b/source/MLibTest/MLibTest/MLibTest.csproj index 59d9e339..dc48a8bc 100644 --- a/source/MLibTest/MLibTest/MLibTest.csproj +++ b/source/MLibTest/MLibTest/MLibTest.csproj @@ -21,7 +21,7 @@ full false bin\Debug\ - DEBUG;TRACE + TRACE;DEBUG prompt 4 @@ -81,9 +81,14 @@ + + + + + @@ -193,5 +198,6 @@ + \ No newline at end of file