Improve visual parent retrieval in ActionMessage#1020
Open
Conversation
Refactor visual parent retrieval logic for PopupRoot handling.
Introduce `popupUI` alias for `Primitives` namespace to streamline `Popup` control references across Windows.UI.Xaml, Avalonia, Microsoft.UI.Xaml, and System.Windows. Fix a bug in `PopupRoot` handling by correcting a variable name and updating logic for setting `pElement`. Remove unused code for cleaner implementation. Ensure consistency and adaptability with conditional compilation.
Refactor visual parent retrieval logic for PopupRoot handling.
Introduce `popupUI` alias for `Primitives` namespace to streamline `Popup` control references across Windows.UI.Xaml, Avalonia, Microsoft.UI.Xaml, and System.Windows. Fix a bug in `PopupRoot` handling by correcting a variable name and updating logic for setting `pElement`. Remove unused code for cleaner implementation. Ensure consistency and adaptability with conditional compilation.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the visual parent retrieval logic in ActionMessage to properly handle PopupRoot elements across different UI platforms (WinUI, UWP, Avalonia, WPF). The change adds platform-specific namespace aliases and implements conditional logic to navigate up the visual tree through popup hierarchies.
Key changes:
- Added
popupUInamespace aliases for all platform-specific conditionals to access Popup primitives - Implemented special handling for PopupRoot elements to correctly traverse the visual tree hierarchy
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Simplified the condition checking for `currentElement` by directly verifying if it is a `popupUI.Popup` and its parent is also a `popupUI.Popup`. This refactoring removes unnecessary nesting and streamlines the logic. Adjusted conditional compilation directives to integrate assignments within the main condition block, enhancing code readability and maintainability.
Updated `Caliburn.Micro.Avalonia.csproj` and `Caliburn.Micro.Maui.csproj` to improve package management and documentation generation: - Added targets for managing project references and reference assemblies. - Prevented building project references when `NoBuild` is true. - Excluded `.xml` files from allowed output extensions. - Enabled XML documentation generation and disabled symbol package generation. Enhanced `ActionMessage.cs` to handle `PopupRoot` elements: - Added logic to determine the parent or placement target of popups. - Used conditional compilation for platform-specific behavior.
Removed logic for handling PopupRoot elements and setting pElement based on WINDOWS_UWP directive. This code was responsible for navigating the visual tree to find the appropriate parent or target for a popup element. Added a logging statement under the AVALONIA directive to log "SetMethodBinding avalonia," indicating a shift in focus towards Avalonia-specific functionality and possibly a change in how popups are managed in the application.
KasperSK
approved these changes
Oct 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refactor visual parent retrieval logic for PopupRoot handling.