I would like to enable a KeyBinding for a DelegateCommand in a Prism4 desktop application. For example, in my XAML file I have this:
<Grid.InputBindings>
<KeyBinding Gesture="CTRL+A" Command="{Binding Command3}"/>
</Grid.InputBindings>
<StackPanel>
<Button Grid.Row="0" Grid.Column="1" Content="HitMe" prism:Click.Command="{Binding Command3}" />
</StackPanel>
and in my ViewModel I have this:
public DelegateCommand<string> Command3 { get; private set; }
private void ExecuteCommand3(string commandParameter)
{
Debug.WriteLine("ExecuteCommand3");
}
private bool CanExecuteCommand3(string commandParameter)
{
return true;
}
When I press the HitMe button the debug line outputs but pressing CTRL+A has no effect.
I have considered using the CommandReference class from TestMvvmExample2341 but that seems to duplicate the functionality of Prism 4 mechanisms.
Is there a an easy way to have CTRL+A invoke the Command3 in Prism4?