Displaying a Message Box (Windows Phone, Windows, Xbox 360)
Describes how to show a message box.
The Complete Sample
The code in this topic shows you the technique. You can download a complete code sample for this topic, including full source code and any additional supporting files required by the sample.
You can use Guide.BeginShowMessageBox to show a system-supplied message box that displays alerts, warnings, and other information to the gamer. This is an asynchronous process for which you can use both polling and callback-style techniques to retrieve user input.
Note
For more information about programming asynchronous methods, see Working with Asynchronous Methods in XNA Game Studio.
To show a message box
Call Guide.BeginShowMessageBox to begin display of the message box.
For example:
List<string> MBOPTIONS = new List<string>();
MBOPTIONS.Add("OK"); string msg = "Text that was typed on the keyboard will be displayed here.\nClick OK to continue..."; Guide.BeginShowMessageBox( mbTitle, msg, MBOPTIONS, 0, MessageBoxIcon.Alert, null, null);
Note
Guide.BeginShowMessageBox has two overloads, one of which takes a player index. It doesn't matter which one you choose, though you should be aware that on Windows Phone and Windows, the player index must always be PlayerIndex.One. The maximum number of buttons you can define for a message box varies by platform. It is currently two on Windows Phone, and three on Xbox 360 and Windows.
When IASyncResult.IsCompleted is true, call Guide.EndShowMessageBox to retrieve the zero-based index of the message box button chosen by the user.
See Also
MessageBoxIcon Enumeration
PlayerIndex Enumeration
IAsyncResult