Hallo zusammen,
ich erhalte manchmal beim Drücken der 'Back' Taste eine Exception.
- $exception {System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at Windows.UI.Popups.MessageDialog.ShowAsync()
at KLON.Pages.Test.<HardwareButtons_BackPressed>d__0.MoveNext()} System.Exception {System.UnauthorizedAccessException}
Mein Code dazu:
async void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
{
e.Handled = true;
TestModel tm = DataContext as TestModel;
if (!tm.Leitner.IsComplete)
{
MessageDialog msg = new MessageDialog("Möchtest Du den Test beenden?", "Test");
msg.Commands.Add(new UICommand("Ja", new UICommandInvokedHandler(CommandHandlers)));
msg.Commands.Add(new UICommand("Nein", new UICommandInvokedHandler(CommandHandlers)));
await msg.ShowAsync();
}
else
{
Frame.BackStack.Clear();
Frame.Navigate(typeof(Pages.MainPage));
}
}
public void CommandHandlers(IUICommand commandLabel)
{
var Actions = commandLabel.Label;
switch (Actions)
{
case "Ja":
Frame.BackStack.Clear();
Frame.Navigate(typeof(Pages.MainPage));
break;
}
}
Die Exception wird ausgelöst bei:
await msg.ShowAsync();
Hat jemand eine Idee warum es manchmal so funktioniert und mal nicht?
Viele Grüße
Thorsten