我不认为我需要粘贴代码。这是C#。WinRT的C#MessageDialog.ShowAsync - 未经授权的访问例外 -
基本上,我有一个MessageDialog Created,显示它,并从一个按钮调用UICommandInvokedHandler。
在那个处理程序中,我做了其他可能导致另一个MessageDialog.ShowAsync被调用的项目。然而,第二次调用却给出了Unathorized Access Exception。
我试过一些事情,如导致尝试强制在用户界面THread上创建新的MessageDialog的事件,但是做了同样的事情。
有关如何解决此问题的任何建议?粗略地说,我试图给一个对话框说“你确定吗?是/否”。如果是的话,它会执行内容,并可以弹出其他对话框给出随机错误信息。
好的代码:
public static async void WriteMessageDialog(string message, string buttonText1, UICommandInvokedHandler handler1, string buttonText2, UICommandInvokedHandler handler2)
{
MessageDialog msgDlg = new MessageDialog(message);
msgDlg.Commands.Add(new UICommand(buttonText1, handler1));
msgDlg.Commands.Add(new UICommand(buttonText2, handler2));
// Set the default button to be enabled and default on escape key pressed
msgDlg.DefaultCommandIndex = 0;
msgDlg.CancelCommandIndex = 0;
// Show the window
await msgDlg.ShowAsync();
}
后来.....
// THey original Message Dialog
RTUtilities.WriteMessageDialog(
_resourceLoader.GetString("DetelePersonConfirm"),
_resourceLoader.GetString("Delete"),
new UICommandInvokedHandler(this.CommandDeletePersonHandler), _resourceLoader.GetString("Cancel"),
new UICommandInvokedHandler(this.CommandCancelHandler));
称这.....
private async void CommandDeletePersonHandler(IUICommand command)
{
MessageDialog msgDlg = new MessageDialog(_resourceLoader.GetString("DeleteIndividualError"));
await msgDlg.ShowAsync();
}
如果您发布一些代码,您有更多的机会获得答案,否则人们不得不猜测很多。 – 2013-04-10 01:20:05
你检查了[这个](http://stackoverflow.com/questions/14488587/how-to-allow-for-multiple-popups-at-once-in-winrt)?如果你发现它工作,然后让我知道。 – Xyroid 2013-04-10 10:12:42