Search code examples
windows-phone-7messageboxback-button

MessageboxResult is Cancel when user clicks back button


I noticed that if some MessageBox appears and you even just have a OK button on it and the user clicks the back button from Windows Phone 7, you will receive Cancel in MessageBoxResult.

Anybody experienced it?


Solution

  •         MessageBoxResult m = MessageBox.Show("something", "something", MessageBoxButton.OK);
            if (m == MessageBoxResult.Cancel)
            {
                MessageBox.Show("cancelled!");
            }
            else 
            {
                MessageBox.Show("not cancelled!");
            }
    

    Edit: Just found some information here

    An excerpt

    When the user closes the MessageBox in a non-standard manner (e.g. by pressing the Back button), the result that is automatically passed as a response is MessageBoxResult.Cancel, even if no Cancel button is pressed.

    From what I can tell from the article, MessageBoxResult.Cancel is what you get when using Windows Phone 7.
    But, when tested in a Windows Phone 7.1(Mango) application, I got a MessageBoxResult.None