I would like to use InvokeCommandAction to send MouseButtonEventArgs.ChangedButton and a parameter of my choice.
I can send the arg value using TriggerParameterPath.
I can send multiple parameters using a MultiBinding along with a IMultiValueConverter.
How can I do both?
Newer Prism versions use the Microsoft.Xaml.Behaviors.Wpf package for the interactivity types, so the
InvokeCommandActiontype from there will be used in the following. For older versions using the legacySystem.Windows.Interactivitytypes, the same is applicable.If you inspect the code for the
InvokeCommandActiontype in theInvoke(object parameter)method, you can see that either theCommandParameteror the event arguments can be passed and if both are specified, theCommandParametertakes precedence. Consequently, by design this is not possible.What you can do is create your own implementation of the
InvokeCommanAction. Unfortunately, the type is markedsealedfor some reason, so you are left to copy the implementation and adapt it.The following serves as an example that you can vary to fit your requirements. Create a type that can hold both the event arguments and the command parameter.
Copy the original code of the
InvokeCommandActionand adapt theInvokemethod like this.The only difference to the original code is that now an instance of
CompositeCommandParameterwill be created with the event arguments and theCommandParameterthat is passed to your bound command.Just for lazyness and easy setup, this would be the full command. As a side note, the
PassEventArgsToCommandmay no longer be needed, as they should always be passed now.