This project has moved. For the latest updates, please go here.

KeyBinding

Feb 28, 2011 at 6:13 PM

Hi,

is it possible  to add a KeyBinding to a DelegateCommand?

I try to add a KeyBinding to the InputBindings collection of a UserControl in XAML but it's not invoked, only if I add it to the main ShellWindow.

TYIA.

 

Coordinator
Mar 1, 2011 at 6:31 PM

Hi Tyia,

Yes this works. Please have a look at the Writer sample application: “Writer.Presentation / Views / MainView.xaml”. This is a UserControl which is hosted inside the ShellWindow.

<UserControl.InputBindings>
    <KeyBinding Command="{Binding NewCommand}" Key="N" Modifiers="Control"/>

jbe


Mar 4, 2011 at 9:43 AM
Edited Mar 4, 2011 at 9:50 AM

I don't seem to get it to work, it never fires if is attached to any UI element other than the main window.

Also my name is not Tyia, TYIA means "Thank You In Advance" ;)

 

Edit: I think I found the answer: http://www.softinsight.com/bnoyes/2008/11/09/TheTruthAboutRoutedCommandsRouting.aspx