From 937f410889434eb97dd310fa7a9b8e230f881a96 Mon Sep 17 00:00:00 2001 From: Liz Hare <103444841+lizharems@users.noreply.github.com> Date: Wed, 21 Aug 2024 12:12:50 -0400 Subject: [PATCH] 2174059 MAUI hit testing ignores pages loaded by PushModalAsync (#24109) * MAUI hit testing ignores pages loaded by PushModalAsync Updated VisualTreeElementExtension to get the MauiWinUiWindow Element, as its content member gets modal content in addition to underlying content * PR Feedback Update the code to use the UI.Xaml.Window instead of the MauiWinUIWindow --- .../src/Core/Extensions/VisualTreeElementExtensions.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Core/src/Core/Extensions/VisualTreeElementExtensions.cs b/src/Core/src/Core/Extensions/VisualTreeElementExtensions.cs index 93bbce1b8afd..0e0424802470 100644 --- a/src/Core/src/Core/Extensions/VisualTreeElementExtensions.cs +++ b/src/Core/src/Core/Extensions/VisualTreeElementExtensions.cs @@ -136,7 +136,12 @@ static List GetVisualTreeElementsWindowsInternal(IVisualTree var visualElements = new List(); if (visualElement is IWindow window) { - uiElement = window.Content?.ToPlatform(); + // Get the UI.Xaml.Window so we catch everything in the app window rather than the frame which doesn't include modal content + var platformView = window.Handler?.PlatformView; + if (platformView is UI.Xaml.Window winUiWindow) + { + uiElement = winUiWindow.Content; + } } else if (visualElement is IView view) {