I don't think I need to paste code. This is C#.
Basically, I have a MessageDialog Created, Show it, and have UICommandInvokedHandler being called from a button.
Inside that Handler, I do other items that could cause another MessageDialog.ShowAsync to be called. However, this second call is giving an Unathorized Access Exception.
I've tried some things like causing an event trying to force the new MessageDialog to be created on the UI THread, but that did the same thing.
Any suggestions on how to get around this? Roughly, I am trying to give a Dialog to say "Are you sure? Yes/No" If yes, it does the guts of execution and can pop up other Dialogs to give random error information.
Ok Code:
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();
}
Later.....
// THey original Message Dialog
RTUtilities.WriteMessageDialog(
_resourceLoader.GetString("DetelePersonConfirm"),
_resourceLoader.GetString("Delete"),
new UICommandInvokedHandler(this.CommandDeletePersonHandler), _resourceLoader.GetString("Cancel"),
new UICommandInvokedHandler(this.CommandCancelHandler));
Calls this.....
private async void CommandDeletePersonHandler(IUICommand command)
{
MessageDialog msgDlg = new MessageDialog(_resourceLoader.GetString("DeleteIndividualError"));
await msgDlg.ShowAsync();
}