EventArgsToCommand

May 27, 2014 at 12:26 PM
Hi Guys,

I'm new to MVVMLight, and have recently found the EventArgsToCommand functionality. I have a quick question, if I'm using the PassEventArgsToCommand property and set it to true, is it possible to send extra parameters, ie. ones not included in the eventargs?
Coordinator
May 28, 2014 at 6:53 PM
Hi,

No, because of the limitations of the ICommand interface (which is .NET, not MVVM Light), you can only pass one parameter. So it is either the CommandParameter, or the EventArgs but not both.

The work around this limitation is to create a new property in your viewmodel and to bind this property to the element that you want to observe in the UI. This way, when the command is executed, you can get access to the property in question.

Cheers
Laurent