当前位置:网站首页>Uwp confirms whether there is pop-up display

Uwp confirms whether there is pop-up display

2022-06-21 22:33:00 zLulus

When the application already has a pop-up window , Show other pop-up windows , Will prompt

 An asynchronous operation did not start normally .

Only a single ContentDialog can be open at any time.
   at Windows.UI.Xaml.Controls.ContentDialog.ShowAsync()
   at .......
   at System.Threading.WinRTSynchronizationContextBase.Invoker.InvokeCore()

Solutions : Determine whether a pop-up window is currently displayed

protected bool IsAnyContentDialogOpen()
{
    return VisualTreeHelper.GetOpenPopups(Window.Current).Count > 0;
}

perhaps

var openedpopups = VisualTreeHelper.GetOpenPopups(Window.Current);
foreach (var popup in openedpopups)
{
   if(popup.Child is ContentDialog)
   {
      // Yes ContentDialog Pop up window displayed 
   }
}

Reference material

How to check if ANY ContentDialog is open?

原网站

版权声明
本文为[zLulus]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206212041017704.html