Thursday, November 20, 2008
Trusted by over 7 million customers!
Silverlight Right Click Fix - Use Your Own Right Click Context Menu In Silverlight!
Minimize
Location: BlogsSilverlight Code & Controls   
Posted by: Ken Dopierala Jr.10/5/2007 11:00 AM
I saw all the posting on the different boards about the default right-click Silverlight context menu being a thorn in the side of coders everywhere. This blog entry introduces a "fix" for it. The solution works for both Javascript and Managed Code Silverlight Applications.

 

Update - 10-5-2007 - CSharp Source Code Is Now Available For This Demo.

I saw all the posting on the different boards about the default right-click Silverlight context menu being a thorn in the side of coders everywhere.  This blog entry introduces a "fix" for it.  The solution works for both Javascript and Managed Code Silverlight Applications.

What I did was added an "oncontextmenu" event capture to the Div that contains the Silverlight plugin.  This event fires a Javascript function that grabs the mouse coordinates and sends them to the Silverlight object.  The Silverlight object figures out if the mouse is over any of the controls you want to change the context menu for (you could also comment out that code and just capture it for your whole Silverlight canvas).  If it is then it does what you tell it to.

The demo and source contain to blocks.  If you right click on the left block a context menu will appear that I created in Silverlight.  If you right click on the right block then you'll get an customized HTML context menu.

 Thanks for reading my blog.  Feel free to contact me at anytime with Silverlight - Browser integration issues.  These are my favorite to solve!

You can view a demo and download the source here: http://www.RealTimeSilverlight.com

Feel free to email me with any feedback: Ken@RTLogicSystems.Com

 

 

Permalink | Trackback

Comments (5)  Add Comment
Re: Silverlight Right Click Fix - Use Your Own Right Click Context Menu In Silverlight!  By Jess on 10/7/2007 5:44 AM
Great Silverlight Articles!<br><br>Jess

Re: Silverlight Right Click Fix - Use Your Own Right Click Context Menu In Silverlight!  By Tom on 10/9/2007 8:09 AM
Great idea, but it doesn't seem to work on Firefox (2.0.0.7). I was able to observe correct behavior in IE7. Both running on Vista.

Re: Silverlight Right Click Fix - Use Your Own Right Click Context Menu In Silverlight!  By Sakthi Sai Saranyan on 10/11/2007 7:19 PM
Great Solution

Re: Silverlight Right Click Fix - Use Your Own Right Click Context Menu In Silverlight!  By Sakthi Sai Saranyan on 10/11/2007 7:20 PM
Great Solution

Re: Silverlight Right Click Fix - Use Your Own Right Click Context Menu In Silverlight!  By jiafeng chen on 12/29/2007 3:38 AM
thank you~<br>you write article very good!!


Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
Nationwide Freight Trucks - Reefer - Expedited - LTL - Truck Load - Brokerage

Free Online Dating Coupons (Match.Com, Date, PerfectMatch, Lavalife and More)



Blog_Archive
Minimize

Print  

Nationwide Building Permits - Courier Services - Expedited Permits - Retail Construction Permits

Who is looking for you online?
Find out now....


Click Here to get 1 month FREE Dedicated Hosting
Trusted by over 7 million customers!

Privacy Statement  |  Terms Of Use
Copyright 2007 by RTLogicSystems.Com