如何在Prism 4中为DelegateCommand启用KeyBinding?

我想在Prism4桌面应用程序中为DelegateCommand启用KeyBinding。例如,在我的XAML文件中,我有这个:
<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>
在我的ViewModel中我有这个:
public DelegateCommand<string> Command3 { get; private set; }

    private void ExecuteCommand3(string commandParameter)
    {
        Debug.WriteLine("ExecuteCommand3");

    }

    private bool CanExecuteCommand3(string commandParameter)
    {
        return true;
    }
当我按下HitMe按钮时,调试行输出但按下CTRL + A无效。 我考虑过使用TestMvvmExample2341中的CommandReference类,但这似乎复制了Prism 4机制的功能。 是否有一种简单的方法让CTRL + A在Prism4中调用Command3?     
已邀请:
就是这样,也许你的问题与你视图中的Focus有关,试试这个: 在运行时将焦点设置在Button上,然后应用击键。另外看看这些帖子: WPF MVVM KeyBinding无法立即识别,并不总是有效 http://joyfulwpf.blogspot.com/2009/05/mvvm-commandreference-and-keybinding.html     

要回复问题请先登录注册