I haven't written a blog for a long time. Recently, I have seen very few articles on Metro style apps. I think it's good to share my experiences after studying it. The code references the example of messagedialog in the message box of msdn. In combination with your own experience.
The message dialog box in the Metro style app displays user help information. The message dialog box is implemented by messagedialog.
1. Custom message boxes. The following is a self-defined message box. The command is the operation you want, which is omitted here (represented by Todo ).
Private async void customcommandbutton_click2 (Object sender, routedeventargs e) {// set the content and title var messagedialog = new messagedialog ("new updates have been found for this program. wocould you like to install the new updates? "," Updates available "); messagedialog. commands. add (New uicommand ("don't install", (command) =>{// todo:}); messagedialog. commands. add (New uicommand ("Install Updates", (command) =>{// todo:}); // sets the default button messagedialog. defacommandcommandindex = 1; await messagedialog. showasync ();}
2. When no button is added, a close button is provided by default.
private async void DefaultCloseCommandButton_Click2(object sender, RoutedEventArgs e) { var messageDialog = new MessageDialog("You've exceeded your trial period."); await messageDialog.ShowAsync(); }
The free content in the pop-up text box has no title.
3. Use the command ID.
Private async void completedcallbackbutton_click (Object sender, routedeventargs e) {var messagedialog = new messagedialog ("new updates have been found for this program. wocould you like to install the new updates? "," Updates available "); // Add the command and command ID messagedialog. commands. add (New uicommand ("don't install", null, 0); messagedialog. commands. add (New uicommand ("Install Updates", null, 1); messagedialog. defaultcommandindex = 1; var commandchosen = await messagedialog. showasync (); Switch (commandchosen. id. tostring () {Case "0": // todo: break; Case "1": // todo: break ;}}
In this example, the command ID is used to perform different operations based on the selected command ID.
4. When you press ESC, cancel the command.
Private async void cancelcommandbutton_click2 (Object sender, routedeventargs e) {var messagedialog = new messagedialog ("no Internet connection has been found. "); // The callback functions of the two commands are the same, different from the preceding inline form. Messagedialog. commands. add (New uicommand ("try again", new uicommandinvokedhandler (this. commandinvokedhandler2); messagedialog. commands. add (New uicommand ("close", new uicommandinvokedhandler (this. commandinvokedhandler2); messagedialog. defaultcommandindex = 0; // when you press ESC, cancel the command to function messagedialog. cancelcommandindex = 1; await messagedialog. showasync ();} private void commandinvokedhandler2 (iuicommand command) {// todo :}
Press the ESC exit button on the keyboard to directly call the exit command. Note that the two commands call the same function commandinvokedhandler2.
The summary of messagedialog will be introduced here first, and new insights will be added later. Bye.