From fc61693b20897ad999171e876e3d1952f9043e37 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Mon, 20 Oct 2025 08:49:38 -0400 Subject: [PATCH 1/8] Improve visual parent retrieval in ActionMessage Refactor visual parent retrieval logic for PopupRoot handling. --- src/Caliburn.Micro.Platform/ActionMessage.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Caliburn.Micro.Platform/ActionMessage.cs b/src/Caliburn.Micro.Platform/ActionMessage.cs index 8e09cf48..814c75be 100644 --- a/src/Caliburn.Micro.Platform/ActionMessage.cs +++ b/src/Caliburn.Micro.Platform/ActionMessage.cs @@ -597,7 +597,16 @@ public override string ToString() } } - currentElement = BindingScope.GetVisualParent(currentElement); + //currentElement = BindingScope.GetVisualParent(currentElement); + var pElement = BindingScope.GetVisualParent(currentElement); + if(pElemenet != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase)) + { + If(currentElement is PopupRoot popupRoot && popupRoot.Parent is Popup popup) + { + pElement = popup.PlacementTarget; + } + } + currentElement = pElement; } #if AVALONIA Log.Info("SetMethodBinding avalonia"); From 1b7032aeb6147190370e1f792bbe3bf6798bb726 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Mon, 20 Oct 2025 09:54:54 -0400 Subject: [PATCH 2/8] Fix typo in conditional statement for PopupRoot --- src/Caliburn.Micro.Platform/ActionMessage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Caliburn.Micro.Platform/ActionMessage.cs b/src/Caliburn.Micro.Platform/ActionMessage.cs index 814c75be..94c3e6a0 100644 --- a/src/Caliburn.Micro.Platform/ActionMessage.cs +++ b/src/Caliburn.Micro.Platform/ActionMessage.cs @@ -601,7 +601,7 @@ public override string ToString() var pElement = BindingScope.GetVisualParent(currentElement); if(pElemenet != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase)) { - If(currentElement is PopupRoot popupRoot && popupRoot.Parent is Popup popup) + if(currentElement is PopupRoot popupRoot && popupRoot.Parent is Popup popup) { pElement = popup.PlacementTarget; } From 95d64ce4d980f85f428fcf42e93dcde99261cd3b Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Tue, 21 Oct 2025 20:23:20 -0400 Subject: [PATCH 3/8] Refactor Popup handling across UI frameworks 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. --- src/Caliburn.Micro.Platform/ActionMessage.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Caliburn.Micro.Platform/ActionMessage.cs b/src/Caliburn.Micro.Platform/ActionMessage.cs index 94c3e6a0..08812d21 100644 --- a/src/Caliburn.Micro.Platform/ActionMessage.cs +++ b/src/Caliburn.Micro.Platform/ActionMessage.cs @@ -14,6 +14,7 @@ using Microsoft.Xaml.Interactivity; using TriggerBase = Microsoft.Xaml.Interactivity.IBehavior; using EventTrigger = Microsoft.Xaml.Interactions.Core.EventTriggerBehavior; + using popupUI = Windows.UI.Xaml.Controls.Primitives; #elif AVALONIA using Avalonia; using Avalonia.Data; @@ -30,6 +31,7 @@ using EventTrigger = Avalonia.Xaml.Interactions.Core.EventTriggerBehavior; using FrameworkElement = Avalonia.Controls.Control; using Avalonia.Input; + using popupUI = Avalonia.Controls.Primitives; #elif WinUI3 using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Data; @@ -40,6 +42,7 @@ using Microsoft.Xaml.Interactivity; using TriggerBase = Microsoft.Xaml.Interactivity.IBehavior; using EventTrigger = Microsoft.Xaml.Interactions.Core.EventTriggerBehavior; + using popupUI = Microsoft.UI.Xaml.Controls.Primitives; #else using System.Windows; using System.Windows.Controls.Primitives; @@ -47,6 +50,7 @@ using System.Windows.Markup; using Microsoft.Xaml.Behaviors; using EventTrigger = Microsoft.Xaml.Behaviors.EventTrigger; + using popupUI = System.Windows.Controls.Primitives; #endif #if NET5_0_WINDOWS || NET6_0_WINDOWS @@ -597,16 +601,20 @@ public override string ToString() } } - //currentElement = BindingScope.GetVisualParent(currentElement); var pElement = BindingScope.GetVisualParent(currentElement); - if(pElemenet != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase)) + if (pElement != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase)) { - if(currentElement is PopupRoot popupRoot && popupRoot.Parent is Popup popup) - { - pElement = popup.PlacementTarget; - } + if (currentElement is popupUI.Popup popupRoot && popupRoot.Parent is popupUI.Popup popup) + { +#if WINDOWS_UWP + pElement = popup.Parent; +#else + pElement = popup.PlacementTarget; +#endif + } } currentElement = pElement; + } #if AVALONIA Log.Info("SetMethodBinding avalonia"); From faee39cc967757df6ea106b91b2a0711e6745962 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Mon, 20 Oct 2025 08:49:38 -0400 Subject: [PATCH 4/8] Improve visual parent retrieval in ActionMessage Refactor visual parent retrieval logic for PopupRoot handling. --- src/Caliburn.Micro.Platform/ActionMessage.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Caliburn.Micro.Platform/ActionMessage.cs b/src/Caliburn.Micro.Platform/ActionMessage.cs index 8e09cf48..814c75be 100644 --- a/src/Caliburn.Micro.Platform/ActionMessage.cs +++ b/src/Caliburn.Micro.Platform/ActionMessage.cs @@ -597,7 +597,16 @@ public override string ToString() } } - currentElement = BindingScope.GetVisualParent(currentElement); + //currentElement = BindingScope.GetVisualParent(currentElement); + var pElement = BindingScope.GetVisualParent(currentElement); + if(pElemenet != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase)) + { + If(currentElement is PopupRoot popupRoot && popupRoot.Parent is Popup popup) + { + pElement = popup.PlacementTarget; + } + } + currentElement = pElement; } #if AVALONIA Log.Info("SetMethodBinding avalonia"); From 6ca2991c9973ab6dc3cd1f4543f134f5c265eed7 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Mon, 20 Oct 2025 09:54:54 -0400 Subject: [PATCH 5/8] Fix typo in conditional statement for PopupRoot --- src/Caliburn.Micro.Platform/ActionMessage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Caliburn.Micro.Platform/ActionMessage.cs b/src/Caliburn.Micro.Platform/ActionMessage.cs index 814c75be..94c3e6a0 100644 --- a/src/Caliburn.Micro.Platform/ActionMessage.cs +++ b/src/Caliburn.Micro.Platform/ActionMessage.cs @@ -601,7 +601,7 @@ public override string ToString() var pElement = BindingScope.GetVisualParent(currentElement); if(pElemenet != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase)) { - If(currentElement is PopupRoot popupRoot && popupRoot.Parent is Popup popup) + if(currentElement is PopupRoot popupRoot && popupRoot.Parent is Popup popup) { pElement = popup.PlacementTarget; } From ee391334e57f52adbfb1a39986119814c45f00ca Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Tue, 21 Oct 2025 20:23:20 -0400 Subject: [PATCH 6/8] Refactor Popup handling across UI frameworks 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. --- src/Caliburn.Micro.Platform/ActionMessage.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Caliburn.Micro.Platform/ActionMessage.cs b/src/Caliburn.Micro.Platform/ActionMessage.cs index 94c3e6a0..08812d21 100644 --- a/src/Caliburn.Micro.Platform/ActionMessage.cs +++ b/src/Caliburn.Micro.Platform/ActionMessage.cs @@ -14,6 +14,7 @@ using Microsoft.Xaml.Interactivity; using TriggerBase = Microsoft.Xaml.Interactivity.IBehavior; using EventTrigger = Microsoft.Xaml.Interactions.Core.EventTriggerBehavior; + using popupUI = Windows.UI.Xaml.Controls.Primitives; #elif AVALONIA using Avalonia; using Avalonia.Data; @@ -30,6 +31,7 @@ using EventTrigger = Avalonia.Xaml.Interactions.Core.EventTriggerBehavior; using FrameworkElement = Avalonia.Controls.Control; using Avalonia.Input; + using popupUI = Avalonia.Controls.Primitives; #elif WinUI3 using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Data; @@ -40,6 +42,7 @@ using Microsoft.Xaml.Interactivity; using TriggerBase = Microsoft.Xaml.Interactivity.IBehavior; using EventTrigger = Microsoft.Xaml.Interactions.Core.EventTriggerBehavior; + using popupUI = Microsoft.UI.Xaml.Controls.Primitives; #else using System.Windows; using System.Windows.Controls.Primitives; @@ -47,6 +50,7 @@ using System.Windows.Markup; using Microsoft.Xaml.Behaviors; using EventTrigger = Microsoft.Xaml.Behaviors.EventTrigger; + using popupUI = System.Windows.Controls.Primitives; #endif #if NET5_0_WINDOWS || NET6_0_WINDOWS @@ -597,16 +601,20 @@ public override string ToString() } } - //currentElement = BindingScope.GetVisualParent(currentElement); var pElement = BindingScope.GetVisualParent(currentElement); - if(pElemenet != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase)) + if (pElement != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase)) { - if(currentElement is PopupRoot popupRoot && popupRoot.Parent is Popup popup) - { - pElement = popup.PlacementTarget; - } + if (currentElement is popupUI.Popup popupRoot && popupRoot.Parent is popupUI.Popup popup) + { +#if WINDOWS_UWP + pElement = popup.Parent; +#else + pElement = popup.PlacementTarget; +#endif + } } currentElement = pElement; + } #if AVALONIA Log.Info("SetMethodBinding avalonia"); From ea4995b3988e77f42135d917e3909addaed25792 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Wed, 22 Oct 2025 18:42:54 -0400 Subject: [PATCH 7/8] Refactor popup handling logic 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. --- src/Caliburn.Micro.Platform/ActionMessage.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Caliburn.Micro.Platform/ActionMessage.cs b/src/Caliburn.Micro.Platform/ActionMessage.cs index 08812d21..cf2b411c 100644 --- a/src/Caliburn.Micro.Platform/ActionMessage.cs +++ b/src/Caliburn.Micro.Platform/ActionMessage.cs @@ -602,16 +602,13 @@ public override string ToString() } var pElement = BindingScope.GetVisualParent(currentElement); - if (pElement != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase)) + if (currentElement is popupUI.Popup popupRoot && popupRoot.Parent is popupUI.Popup popup && pElement != null) { - if (currentElement is popupUI.Popup popupRoot && popupRoot.Parent is popupUI.Popup popup) - { #if WINDOWS_UWP - pElement = popup.Parent; + pElement = popup.Parent; #else - pElement = popup.PlacementTarget; + pElement = popup.PlacementTarget; #endif - } } currentElement = pElement; From e0101fbf3272f68655fcb49ec6ef5c38fd298fe0 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Wed, 22 Oct 2025 19:38:16 -0400 Subject: [PATCH 8/8] Refactor popup handling and add Avalonia logging 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. --- src/Caliburn.Micro.Platform/ActionMessage.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/Caliburn.Micro.Platform/ActionMessage.cs b/src/Caliburn.Micro.Platform/ActionMessage.cs index 507572b9..48888e72 100644 --- a/src/Caliburn.Micro.Platform/ActionMessage.cs +++ b/src/Caliburn.Micro.Platform/ActionMessage.cs @@ -612,19 +612,7 @@ public override string ToString() } currentElement = pElement; - var pElement = BindingScope.GetVisualParent(currentElement); - if (pElement != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase)) - { - if (currentElement is popupUI.Popup popupRoot && popupRoot.Parent is popupUI.Popup popup) - { -#if WINDOWS_UWP - pElement = popup.Parent; -#else - pElement = popup.PlacementTarget; -#endif - } - } - currentElement = pElement; + } #if AVALONIA