Shortcut Keys with RelayCommands

Mar 20, 2010 at 8:27 PM
Edited Mar 20, 2010 at 8:28 PM

Oh Hai thare.

I'm developing an application and I'm using the RelayCommand. Now I want to bind KeyGestures to one but I have yet found any how-to yet.
Is this possible in some way?

Mar 20, 2010 at 8:50 PM

Nevermind, I just realised I didn't do 'nuff research and I spelled my binding wrong so it would've worked from the beginning x)...

Anyway for those who want to know, what I did was just to bind a KeyBinding to my RelayCommand in XAML like this:

 

 

<Window.InputBindings>
        <KeyBinding Command="{Binding Path=NewCampaignCommand}" Key="N" Modifiers="Ctrl" />
</Window.InputBindings>

 

This apperently only works with .NET 4.0. In earlier versions of .NET the Command Property in Keybinding didn't support binding at all, at least that's what I've read so I can't really say for sure.