Summary of Metro style app message box messagedialog

Source: Internet
Author: User

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.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.