This project is read-only.

Shortcut Keys with RelayCommands

Mar 20, 2010 at 9:27 PM
Edited Mar 20, 2010 at 9: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 9: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:



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


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.