2013-04-18 140 views
0

我的代碼:MessageDialog在Windows 8 XAML

  MessageDialog msg = new MessageDialog("Are you sure to cancel the booking?", "Confirmation"); 
      msg.Commands.Add(new UICommand("Confirm", new UICommandInvokedHandler(CommandHandler))); 
      msg.Commands.Add(new UICommand("Cancel", new UICommandInvokedHandler(CommandHandler))); 
      msg.DefaultCommandIndex = 1; 
      msg.CancelCommandIndex = 1; 
      await msg.ShowAsync(); 

private async void CommandHandler(IUICommand command) 
    { 
     var commandLabel = command.Label; 
     switch (commandLabel) 
     { 
      case "Confirm": 
       CancelBookingTickets(); 
       break; 
      case "Cancel": 
       break; 

     } 


    } 

protected async void CancelBookingTickets() 
    {   

      MessageDialog msg1 = new MessageDialog("The cancellation process is complete", "Complete"); 
      await msg1.ShowAsync();    
    } 

我想使用嵌套MessageDialog框在我的Windows 8的XAML應用程序,但是當我到達的msg1.ShowAsync(),它激發一個異常說:「訪問被拒絕」。

有人可以幫我解決這個問題嗎?

回答