Getting Started with Windows 8 Development (16) Windows 8 Right-click menu

Source: Internet
Author: User

In a control in Windows 8, there are righttapped events for input controls such as contextmenuopening events and button, such as TextBox, that are not input controls.

This article will narrator the use of two events. Of these two events

PopupMenu is the specific class of the right-click pop-up menu.

First we look at the instantiation of the specific menu class and get the project code

<summary>///Set Right click on specific processing details///</summary>///<param name= "Sender" ></p aram> public async void Setrightclick (object sender) {//Add menus popupmenu menu =
            New PopupMenu ();
            MENU.COMMANDS.ADD (New Uicommand ("copy 0", NULL, 0));
            MENU.COMMANDS.ADD (New Uicommand ("Cut 1", NULL, 1);
            MENU.COMMANDS.ADD (New Uicommand ("Paste 2", NULL, 2));
            MENU.COMMANDS.ADD (New Uicommandseparator ());
            MENU.COMMANDS.ADD (New Uicommand ("full screen", NULL, 3);
            MENU.COMMANDS.ADD (New Uicommand ("Snap screen", NULL, 4)); Gets the selected menu item var cmd = await menus.
            Showforselectionasync (getrectposition (FrameworkElement) sender)); if (cmd!= null) {switch (int) cmd. ID) {Case 0:tbtext.text = "Selected (" + cmd). Label + "), whose ID is" + cmd. "
                        Id; Break; Case 1:tbtext.text = "Selected (" + cmd). Label + "), whose ID is" + cmd. "
                        Id;
                    Break Case 2:tbtext.text = "Selected (" + cmd). Label + "), whose ID is" + cmd. "
                        Id;
                    Break Case 3:tbtext.text = "Selected (" + cmd). Label + "), whose ID is" + cmd. "
                        Id;
                    Break Case 4:tbtext.text = "Selected (" + cmd). Label + "), whose ID is" + cmd. "
                        Id;
                Break
            } else {tbtext.text = "context menu";  }//Get menu location Rect getrectposition (frameworkelement element) {Generaltransform Btnform = element.
            Transformtovisual (NULL); Point point = Btnform.
            Transformpoint (new Point ()); Return to New Rect (Point, New Size (Element). ActualWidth, Element.
        ActualHeight)); }

Related Article

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.