MVVM Light Passing pressed key through CommandParameter

Saturday, May 3, 2014

I would like to know if there's a way to pass the pressed key to my actions through CommandParameter. I want to know which key have been pressed before the action gets allowed to execute


Here is my XAML



<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyDown">
<i:InvokeCommandAction Command="{Binding Path=ParseCommand}" CommandParameter=""/>
</i:EventTrigger>
</i:Interaction.Triggers>


My ViewModel



public class MainViewModel : ViewModelBase
{
public RelayCommand<EventArgs> ParseCommand { get; set; }

public MainViewModel()
{
this.ParseCommand = new RelayCommand<EventArgs>(ParseLineExecute, CanParseLine);
}

public bool CanParseLine(EventArgs e)
{
return true;
}

public void ParseLineExecute(EventArgs e)
{
//something to do
}
}






http://ift.tt/1mqvWHA