Note – these posts are put together after a short time with Silverlight 4 as a way of providing pointers to some of the new features that Silverlight 4 has to offer. I’m posting these from the PDC as Silverlight 4 is announced for the first time so please bear that in mind when working through these posts.
Something that I’ve seen people ask for in Silverlight since day 1 is support for the right mouse button. Up until Silverlight 3, the right mouse button has been reserved for raising a single menu option “Silverlight” which then displays the details about the Silverlight plug-in itself including the version information, update configuration, DRM configuration and isolated storage configuration.
In Silverlight 4, this is still the default behaviour for the right mouse button but it’s also possible to use new MouseRightButtonDown and MouseRightButtonUp events in order to handle the right mouse menu.
These new events are introduced on the UIElement class so pretty much impact everything and they work in a similar manner to the existing MouseLeftButtonDown and MouseLeftButtonUp events and are routed events.
If a handler for a MouseRightButtonDown event handles the event by setting MouseButtonEventArgs.Handled to true then the default Silverlight right mouse context menu will not be displayed.
In which case – how does a user get to that configuration dialog for Silverlight? Silverlight 4 installs a new Start Menu shortcut;
which launches the configuration dialog that is usually displayed on the right mouse menu.
The usual thing to do when handling a right-mouse click is to display a context menu – there’s no new context menu class in Silverlight 4 that enables this for you so you’re really into “roll your own” territory at this point or into looking for 3rd parties to provide controls with that kind of functionality.