Windows 8 context menu

Source: Internet
Author: User
Context Menu example this example shows how to create a context menu and how to replace the default context menu text. This example uses Windows. UI. The popupmenu and oncontextmenu events are displayed. This example demonstrates the two tasks: • create a context menu to display as a file • Replace the default command with the text displayed in the context menu to understand the selection command and design a context menu, see the context menu of the Guidelines and checklists. Additional APIs for this example include: • uicommand class • uicommandseparator class async Void Scenario2textbox_contextmenuopening ( Object Sender, contextmenueventargs E)
{
// Create a menu and add commands specifying an id value for each instead of a delegate.
VaR Menu = New Popupmenu ();
Menu. commands. Add ( New Uicommand ( " Copy " , Null , 1 ));
Menu. commands. Add ( New Uicommandseparator ());
Menu. commands. Add ( New Uicommand ( " Highlight " , Null , 2 ));
Menu. commands. Add ( New Uicommand ( " Look up on dictionary " , Null , 3 ));

// We don't want to obscure content, so pass in a rectangle representing the sender of the context menu event.
// We registered command callbacks; no need to await and handle context menu completion
VaR Chosencommand = await menu. showforselectionasync (getelementrect (frameworkelement) sender ));
If (Chosencommand! = Null )
{
Switch (( Int ) Chosencommand. ID)
{
Case 1 :
Output2text. Text = " ' " + Chosencommand. Label + " '( " + Chosencommand. Id. tostring () + " ) Selected " ;
Break ;

Case 2 :
Output2text. Text =" ' " + Chosencommand. Label + " '( " + Chosencommand. Id. tostring () + " ) Selected " ;
Break ;

Case 3 :
Output2text. Text = " ' " + Chosencommand. Label + " '( " + Chosencommand. Id. tostring () + " ) Selected " ;
Break ;
}
}
Else
{
Output2text. Text = " Context Menu dismissed " ;
}

}

Complete example:/files/risk/windows8/upload/download ticket sample.rar

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.