This project is read-only.


Event to Command


Could you please support Event to Command in Prism? There are a few numbers of MVVM frameworks that support EventToCommand. Even we can copy the code or repeat the same thing in our own way, It would be the best if we have official support from Prism Framework.
One suggestion that I like to suggest for implementing Event to Command is that VM should have the reference to control. For example: If I'm using third-party control in View, but my view model shouldn't aware of that third-party control. The max scope of this third-party control should be only in View and attached property (not in ViewModel).
We will need a lot of tricks when it comes to usability. WPF strong binding is great and what Prism supports so far is also very good for developing WPF/Silverlight business application. But there are some scenarios that we need events (this is where Event to Command comes into picture.), setting focus or handling mouse or etc.
Michael Sync
Closed May 1, 2014 at 7:20 PM by blainew
We added this capability in Prism 5.0 for WPF.


weitzhandler wrote Jan 9, 2012 at 12:25 PM

Very compelling.

aadami wrote Mar 8, 2012 at 6:58 PM


For those interested in this subject, you might find useful to know that in order to achieve event-to-command functionality, it’s possible to use Expression Blend’s EventTrigger and InvokeCommandAction like this:

However, Blend’s built-in InvokeCommandAction does not update the enabled state of the control if the ICommand changes it, which might be useful in certain scenarios. To support this kind of scenarios, since Prism 4.1 release (, a custom InvokeCommandAction is provided, which can be used in the same way as Blend’s, but it also updates the control's enabled state appropriately:


Agustin Adami

albertod wrote Jun 3, 2012 at 4:46 PM

Very useful.
Is it possible to pass to "MyCommand" a sort of EventArgs argument, to allow the command to know which key has been pressed?

aadami wrote Jun 5, 2012 at 5:51 PM


Based on my understanding, currently the InvokeCommandAction provided with Prism, uses the CommandParameter specified in the CommandParameterProperty for command invocation, this can be seen in the following lines of the InvokeCommandAction class:

// This parameter is ignored; the CommandParameter specified in the CommandParameterProperty is used for command invocation.
protected override void Invoke(object unusedParameter)

Hence, if you need to retrieve the EventArgs and pass them to the command through the CommandParameter property, I believe you might find the following blog post useful:

Silverlight Commands Hacks: Passing EventArgs as CommandParameter to DelegateCommand triggered by EventTrigger

I hope you find this handy,

Agustin Adami

vikram30capri wrote Jul 20, 2012 at 10:20 AM

MVVM LightTool KIt EventToCommand behavior, bind any event of any UI element to an ICommand, for example on the ViewModel, directly in XAML. This makes using Commands much easier, without writing code behind. One can even get the EventArgs of the fired event directly in the ViewModel to handle it. Please include this cool feature in PRISM, else developrs have to write a lot of code to handle these scenarios.

aadami wrote Oct 23, 2012 at 5:46 PM


For those interested in using the Prism's InvokeCommandAction, take into account that this implementation is located in the Microsoft.Practices.Prism.Interactivity assembly and a reference to this assembly will have to be added to the corresponding project and Xaml file in order to use it (e.g xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Interactivity;assembly=Microsoft.Practices.Prism.Interactivity").

Note, that currently this is not mentioned in the Prism's documentation.


Agustin Adami