MessageBox.Show Method (String)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Displays a message box that contains the specified text and an OK button.
Assembly: System.Windows (in System.Windows.dll)
Parameters
- messageBoxText
- Type: System.String
The message to display.
| Exception | Condition |
|---|---|
| ArgumentNullException | messageBoxText is Nothing. |
Windows Phone 8: In Windows Phone 8 if you call Show(String) method from the app Activated or Launching event handlers an InvalidOperationException is thrown with the message Error Displaying MessageBox. Alternatively, you should call the Show method from the Page.OnNavigatedTo(NavigationEventArgs) method.
In addition, in Windows Phone 8, if you call Show in OnBackKeyPress(CancelEventArgs) or a handler for the BackKeyPress event, the app will exit. You can work around this by calling Show on a different thread described in the following steps.
Override BackKeyPress or create a handler for the BackKeyPress event,
Set the Cancel to true to cancel the back key press action
Dispatch a method that shows the MessageBox
If the user chooses to leave the app, call Terminate, otherwise do nothing.
The message box is modal, which means that the user must tap OK to dismiss the message.