当应用已存在弹窗时,再显示其他弹窗,会提示
某个异步操作没有正常启动。
Only a single ContentDialog can be open at any time.
at Windows.UI.Xaml.Controls.ContentDialog.ShowAsync()
at .......
at System.Threading.WinRTSynchronizationContextBase.Invoker.InvokeCore()
解决思路:判断当前是否有弹窗被展示
protected bool IsAnyContentDialogOpen()
{
return VisualTreeHelper.GetOpenPopups(Window.Current).Count > 0;
}
或者
var openedpopups = VisualTreeHelper.GetOpenPopups(Window.Current);
foreach (var popup in openedpopups)
{
if(popup.Child is ContentDialog)
{
//有ContentDialog弹窗被展示
}
}