Tip: Right-click a menu in Silverlight

Source: Internet
Author: User

This essay shields the SL application from the default right-click menu and uses its own right-click menu.

First, you must<Asp:Silverlight>LabelWindowlessSet the attribute to true. This step is very important. Remember!

Then, write your right-click menu control, which can be border or other

Finally, the contextmenuinterceptor class is used to load the right-click menu.CodeAs follows:

 

Public Partial ClassPage: usercontrol
 
{
 
Contextmenuinterceptor _ CMI =Null;
PublicPage ()
 
{
 
Initializecomponent ();
_ CMI =NewContextmenuinterceptor (myfield );
 
}
 
}
 
 
Public ClassContextmenuinterceptor
 
{
Uielment textfield;
 
 
 
PublicContextmenuinterceptor (uielement textfield)
{
 
Textfield = textfield;
 
Htmlpage. Document. attachevent ("Oncontextmenu",This. Oncontextmenu );
}
 
 
 
Private VoidOncontextmenu (ObjectSender, htmleventargs E)
{
 
Textfield. Text ="Right clicked blocked"+ E. offsetx +","+ E. offsety;
 
E. preventdefault ();
}
 
}

 

 

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.