locked
MessageDialog Access Denied Exception in wp8.1 app RRS feed

  • Question

  • UnauthorizedAccessException - Access Denied when two message box is appear.

    DesertQueen

    Sunday, August 16, 2015 2:02 PM

Answers

  • Hi DevWP,

    You can handle the backpress using HardwareButtonsAPi.

    Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s,args) => {
                    btn.IsEnabled = true;
                };

    Let me know if that worked.


    Please close the threads by marking appropriate reply as an answer

    • Marked as answer by DevWP Tuesday, August 18, 2015 8:41 AM
    Tuesday, August 18, 2015 7:37 AM

All replies

  • Hi,

    This question does happen when two MessageDialog show together, and I think the best way to solve this problem is to remove the first MessageDialog and then show the other one. And I think this is impossible to show two MessageDialogs at the same time in Windows Phone apps but possible in Windows 10 Store apps and Windows 8.1 Store apps.

    Sunday, August 16, 2015 3:21 PM
  •  This occur when i click button twice , How to close the MessageDialog from code ?

    DesertQueen

    Monday, August 17, 2015 11:31 AM
  • Hi DevWP,

    You have to handle the UI thread for the MessageDialog by using Dispatcher.RunAsync and also you can disable the second click on the button to avoid displaying the MessageDialog multiple times.

    Here is a sample

    MessageDialog m = new MessageDialog("HELLO"); private async void btn_Click(object sender, RoutedEventArgs e) { btn.IsEnabled = false; //Disable button for second click m.Commands.Add(new UICommand("Ok", new UICommandInvokedHandler(this.OkCommandClickEvent))); //Add new Command and attaching click event await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,async () => { await m.ShowAsync(); // handling UI thread }); } void OkCommandClickEvent(IUICommand command) { btn.IsEnabled = true; // Enable button on clicking "Ok" m.Commands.Remove(command); //removing the command

    }

    Let me know if that helped you.


    Please close the threads by marking appropriate reply as an answer



    Monday, August 17, 2015 12:56 PM
  • I'm using mvvm in my app so how to enable the button if user  BackKeyPress and MessageDialog  dismissed without clicking Ok  button. 


    DesertQueen

    Tuesday, August 18, 2015 7:29 AM
  • Hi DevWP,

    You can handle the backpress using HardwareButtonsAPi.

    Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s,args) => {
                    btn.IsEnabled = true;
                };

    Let me know if that worked.


    Please close the threads by marking appropriate reply as an answer

    • Marked as answer by DevWP Tuesday, August 18, 2015 8:41 AM
    Tuesday, August 18, 2015 7:37 AM