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
