This project has moved and is read-only. For the latest updates, please go here.

Event2Command for RightMouseButton

Jan 10, 2010 at 5:12 PM

SL4 support RightMouse button clicks, but the event handler needs to be able to set EventHandled. I am not sure if the Event2Command  behavior does this...

Jan 11, 2010 at 9:34 AM


EventToCommand does not set Handled to true automatically, that would break too many routed event scenarios. However, with the latest version of EventToCommand, you can set PassEventArgsToCommand to true on the EventToCommand instance, and use a RelayCommand<EventArgs> as command. This will set the parameter of the command to the EventArgs where you can set Handled to true from your ViewModel directly.

That said, I am not sure that it is correct that you need to set Handled to true explicitly. I think that SL4 will execute the command as soon as you add an event handler to MouseRightButtonDown. The Silverlight context menu is only displayed if there is no event handler for that event. At least that's what I heard and what I observe in SL4 beta.