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 ();
}
}