Sep 4, 2008 at 2:01 PM
I am trying to create a KeyBinding for my command of type DelegateCommand in a presenter. I didn't find any sample source code with a KeyBinding.
I understand that it is impossible to create it in the XAML code because the following code do not work since the KeyBinding.Command property is not a DependencyProperty:
    <KeyBinding Command="{Binding CreateVoiceInteractionCommand}" Gesture="CTRL+F2"/>
So I do the following in the c# code:
   InputBindings.Add(new KeyBinding(Model.CreateVoiceInteractionCommand, Key.F2, ModifierKeys.Control));

What is the best practice about shortcut keys? Moreover, I get some focus issue when I add a View in a Region ! So, the shortcut are not always working :-)

Sep 4, 2008 at 3:43 PM
Edited Sep 4, 2008 at 11:24 PM

I beleive I read in their documentation that you cannot substitute Commands with DelegateCommands in CommandBinding scenarios.

Andres Olivares
Sep 4, 2008 at 3:46 PM
Edited Sep 4, 2008 at 11:25 PM
Can DelegateCommands be replaced with Routed Commands?

"No, because both are meant for two different purposes. Routed commands, suchas Cut, Copy, and Paste, are meant for controls withcommand binding that live within the logical tree and that will have the focusfor the intent of the command. They can also be used for general purposes if itis acceptable to put centralized command handling at the root window or pageelement and have it as part of the view. However, that approach does not scalefor composite applications, so the DelegateCommand approach allows you tohave the flexibility of multiple command handlers that live outside the logicaltree.

From CAG Help Files - Technical Concepts -> Commands

Hope this helps,

Andres Olivares
Sep 4, 2008 at 4:43 PM
I was on the wrong way, so thank you for your explanations.