未验证 提交 76335739 编写于 作者: M Martin Zikmund 提交者: GitHub

Merge pull request #11723 from unoplatform/dev/mazi/keep-nondismissable-popups

fix: App deactivation should close only light dismiss popups
......@@ -57,12 +57,12 @@ namespace Uno.UI.Controls
// Dismiss on device rotation: this reproduces the windows behavior
UIApplication.Notifications
.ObserveDidChangeStatusBarOrientation((sender, args) =>
VisualTreeHelper.CloseAllPopups(WinUICoreServices.Instance.ContentRootCoordinator.CoreWindowContentRoot.XamlRoot));
VisualTreeHelper.CloseLightDismissPopups(WinUICoreServices.Instance.ContentRootCoordinator.CoreWindowContentRoot.XamlRoot));
// Dismiss when the app is entering background
UIApplication.Notifications
.ObserveWillResignActive((sender, args) =>
VisualTreeHelper.CloseAllPopups(WinUICoreServices.Instance.ContentRootCoordinator.CoreWindowContentRoot.XamlRoot));
VisualTreeHelper.CloseLightDismissPopups(WinUICoreServices.Instance.ContentRootCoordinator.CoreWindowContentRoot.XamlRoot));
}
// This will handle when the status bar is showed / hidden by the system on iPhones
......
......@@ -259,7 +259,7 @@ namespace Windows.UI.Xaml
base.OnPause();
// TODO Uno: When we support multi-window, this should close popups for the appropriate XamlRoot #8341.
VisualTreeHelper.CloseAllPopups(WinUICoreServices.Instance.ContentRootCoordinator.CoreWindowContentRoot.XamlRoot);
VisualTreeHelper.CloseLightDismissPopups(WinUICoreServices.Instance.ContentRootCoordinator.CoreWindowContentRoot.XamlRoot);
DismissKeyboard();
}
......
......@@ -188,6 +188,14 @@ namespace Windows.UI.Xaml.Media
}
}
internal static void CloseLightDismissPopups(XamlRoot xamlRoot)
{
foreach (var popup in GetOpenPopups(xamlRoot.VisualTree).Where(p => p.IsLightDismissEnabled))
{
popup.IsOpen = false;
}
}
internal static void CloseAllFlyouts(XamlRoot xamlRoot)
{
foreach (var popup in GetOpenFlyoutPopups(xamlRoot))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册