Skip to content

Commit 95d64ce

Browse files
committed
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.
1 parent 1b7032a commit 95d64ce

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Caliburn.Micro.Platform/ActionMessage.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Microsoft.Xaml.Interactivity;
1515
using TriggerBase = Microsoft.Xaml.Interactivity.IBehavior;
1616
using EventTrigger = Microsoft.Xaml.Interactions.Core.EventTriggerBehavior;
17+
using popupUI = Windows.UI.Xaml.Controls.Primitives;
1718
#elif AVALONIA
1819
using Avalonia;
1920
using Avalonia.Data;
@@ -30,6 +31,7 @@
3031
using EventTrigger = Avalonia.Xaml.Interactions.Core.EventTriggerBehavior;
3132
using FrameworkElement = Avalonia.Controls.Control;
3233
using Avalonia.Input;
34+
using popupUI = Avalonia.Controls.Primitives;
3335
#elif WinUI3
3436
using Microsoft.UI.Xaml;
3537
using Microsoft.UI.Xaml.Data;
@@ -40,13 +42,15 @@
4042
using Microsoft.Xaml.Interactivity;
4143
using TriggerBase = Microsoft.Xaml.Interactivity.IBehavior;
4244
using EventTrigger = Microsoft.Xaml.Interactions.Core.EventTriggerBehavior;
45+
using popupUI = Microsoft.UI.Xaml.Controls.Primitives;
4346
#else
4447
using System.Windows;
4548
using System.Windows.Controls.Primitives;
4649
using System.Windows.Data;
4750
using System.Windows.Markup;
4851
using Microsoft.Xaml.Behaviors;
4952
using EventTrigger = Microsoft.Xaml.Behaviors.EventTrigger;
53+
using popupUI = System.Windows.Controls.Primitives;
5054
#endif
5155

5256
#if NET5_0_WINDOWS || NET6_0_WINDOWS
@@ -597,16 +601,20 @@ public override string ToString()
597601
}
598602
}
599603

600-
//currentElement = BindingScope.GetVisualParent(currentElement);
601604
var pElement = BindingScope.GetVisualParent(currentElement);
602-
if(pElemenet != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase))
605+
if (pElement != null && currentElement.GetType().Name.Equals("PopupRoot", StringComparison.OrdinalIgnoreCase))
603606
{
604-
if(currentElement is PopupRoot popupRoot && popupRoot.Parent is Popup popup)
605-
{
606-
pElement = popup.PlacementTarget;
607-
}
607+
if (currentElement is popupUI.Popup popupRoot && popupRoot.Parent is popupUI.Popup popup)
608+
{
609+
#if WINDOWS_UWP
610+
pElement = popup.Parent;
611+
#else
612+
pElement = popup.PlacementTarget;
613+
#endif
614+
}
608615
}
609616
currentElement = pElement;
617+
610618
}
611619
#if AVALONIA
612620
Log.Info("SetMethodBinding avalonia");

0 commit comments

Comments
 (0)