Table of Contents

Class MessageBox

Namespace
Microsoft.Xna.Framework.Input
Assembly
MonoGame.Framework.dll
public static class MessageBox
Inheritance
MessageBox
Inherited Members

Properties

IsVisible

public static bool IsVisible { get; }

Property Value

bool

Methods

Cancel(int?)

Hides the message box interface and returns the parameter as the result of Show(string, string, IEnumerable<string>)

public static void Cancel(int? result)

Parameters

result int?

Result to return

Examples

var colorTask = MessageBox.Show("Color", "What's your favorite color?", new[] { "Red", "Green", "Blue" });
MessageBox.Cancel(0);
var color = await colorTask;

Exceptions

Exception

Thrown when the message box is not visible

Show(string, string, IEnumerable<string>)

Displays the message box interface asynchronously.

public static Task<int?> Show(string title, string description, IEnumerable<string> buttons)

Parameters

title string

Title of the message box.

description string

Description of the message box.

buttons IEnumerable<string>

Captions of the message box buttons. Up to three supported.

Returns

Task<int?>

Index of button selected by the player. Null if back was used.

Examples

var color = await MessageBox.Show("Color", "What's your favorite color?", new[] { "Red", "Green", "Blue" });

Exceptions

Exception

Thrown when the message box is already visible