Fix Floating Window Closing Behavior and Visibility Handling #506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses several issues related to closing floating windows (LayoutAnchorableFloatingWindowControl and LayoutDocumentFloatingWindowControl) using standard Windows mechanisms (Taskbar 'X' button, Alt+F4) and improves visibility handling for floating document windows.
Related issues this might solve:
#368
Bugs Fixed:
LayoutDocumentFloatingWindowControl
) could potentially bypass parts of the standard AvalonDock closing validation and execution logic when closed via OS commands.LayoutAnchorableFloatingWindowControl
) lacked specific handling for OS close commands, potentially leading to the window being destroyed directly by the OS, bypassing AvalonDock's hide/close logic entirely.CloseCommand
orHideCommand
overrides (e.g., set via styles) could be ignored when closing through OS mechanisms.LayoutDocumentFloatingWindowControl
lacked the mechanism to automatically hide its WPF window view when its underlying model became effectively invisible (e.g., all contained anchorables were hidden). Conversely, it couldn't automatically reappear when the model became visible again. This resulted in empty floating windows remaining visible after closing via the taskbar 'X' if they contained only hidden anchorables.LayoutDocumentPaneGroup.GetVisibility()
always returnedtrue
, preventing the correct propagation of visibility changes up the layout tree, which contributed to the floating document window visibility issue.Summary of Changes:
OnClosing
Methods: TheOnClosing
overrides in bothLayoutAnchorableFloatingWindowControl
andLayoutDocumentFloatingWindowControl
have been substantially rewritten to serve as the single, reliable entry point for user-initiated window closing.LayoutDocument
andLayoutAnchorable
children during validation and execution phases.CanClose
/CanHide
properties, internalTestCanClose
/TestCanHide
, specific manager events (DocumentClosing
,AnchorableClosing
,AnchorableHiding
via new helper methods), and commandCanExecute
.CloseCommand
/HideCommand
) first, then falling back to default internal logic, and finally raising the correct corresponding manager events (DocumentClosed
,AnchorableClosed
,AnchorableHidden
).e.Cancel = true
) is now correctly cancelled only if at least one child element was hidden and none were closed permanently, ensuring the floating container persists for hidden items.LayoutDocumentFloatingWindowControl
: ImplementedEnableBindings
/DisableBindings
and added event handlers (_model_IsVisibleChanged
,Model_PropertyChanged
forIsVisible
), mirroringLayoutAnchorableFloatingWindowControl
. This ensures the window'sVisibility
now correctly synchronizes with its model'sIsVisible
state, allowing it to hide and reappear automatically.LayoutDocumentPaneGroup.GetVisibility()
: Fixed the method to returntrue
only when it contains visible children, enabling correct visibility updates in the layout hierarchy.WM_CLOSE
handling.