Messagedialog Overview
Messagedialog refers to the dialog box.
The dialog box contains up to three commands in the command bar. If we specify any commands, a default command will be added to the dialog box to close the dialog box.
When the dialog box pops up, all the elements in the interface will be displayed below the dialog box, and any touch events will be blocked until the user responds to the dialog box.
Additional dialog boxes should be used sparingly.
Note: The MessageBox object is canceled in the Windows 8 style application and replaced by the Messagedialog object.
Messagedialog Common Properties and methods
The Messagedialog class contains two types of constructors:
1) messagedialog (String)
Public Messagedialog (string content);
The content parameter represents the information that is displayed to the user in the dialog box.
2) Messagedialog (string,string)
Public Messagedialog (string content, string title);
The content parameter represents the information that is displayed in the dialog box to the user, and the title parameter represents the caption information displayed in the dialog box.
Messagedialog Class Common methods:
1) Showasync ()
Public iasyncoperation<iuicommand> Showasync ();
Displays the dialog box asynchronously.
Messagedialog Class Common Properties:
1 Cancelcommandindex property: Gets or sets the index of the cancellation command, the user presses the ESC key and executes the cancellation command;
2 Commands property: Gets the command displayed in the command bar of the dialog box;
3 content property: Gets or sets the main contents displayed in the dialog box;
4 Defaultcommandindex Property: Gets or sets the index of the default command, and the user presses the ENTER key to execute the default command;
5 Options Property: Gets or sets the selected item in the dialog box;
6 Title Property: Gets or sets the caption in the dialog box;
Note: The Messagedialog class is not very optimized and we need to consider its impact in the thread model. In addition, you can refer to multithreading in Windows 8 Store applications: Using Windows Run-time objects in a multithreaded environment.
How to build Messagedialog
The effects of common Messagedialog objects rendering are as follows:
Effect 1: Default Shutdown command
No command to close the dialog box is set in C # code. If we do not set the shutdown command, the system adds a shutdown command by default.
Private async void Messagedialogshow ()
{
var messagedialog = new Messagedialog ("Default shutdown Command");
await Messagedialog.showasync ();
}