Yes you can, like below:
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown" >
<cmd:EventToCommand Command="{Binding EmployeeViewM.MeasurementEndExecution}" CommandParameter="Process"/>
</i:EventTrigger>
</i:Interaction.Triggers>
And/OR
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown" >
<cmd:EventToCommand Command="{Binding EmployeeViewM.MeasurementEndExecution}" CommandParameter="Non-Process"/>
</i:EventTrigger>
</i:Interaction.Triggers>
Hopefully your RelayCommand
(or ICommand
implementation) is already accepting CommandParameter
. Like below.
public class RelayCommand : ICommand
{
#region Fields
readonly Action<object> _execute;
readonly Predicate<object> _canExecute;
#endregion // Fields
#region Constructors
public RelayCommand(Action<object> execute)
: this(execute, null)
{
}
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute;
_canExecute = canExecute;
}
#endregion // Constructors
#region ICommand Members
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute(parameter);
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameter)
{
_execute(parameter);
}
#endregion // ICommand Members
}
CommandParameter
, and it haven't to be astring
, it can be anything you want and it can bind to any property you want. If you have 2 windows, in the first you can pass the string "process" and in the second "non-process". The method that the command raises has a parameter of typeobject
, and it is exactly the parameter that the window passes to the VM. - Massimiliano Kraus