Possible Duplicate:
Binding a WPF ShortCut Key to a Com开发者_JS百科mand in the ViewModel
On a WPF window I have a menu-item that is bound to a command in the ViewModel:
<MenuItem Header="_Edit page" Command="{Binding EditCommand}"/>
The command is a RelayCommand which forwards the command to a method:
EditCommand = new RelayCommand(() => editPage());
I want to assign a shortcut key Ctrl+E to the command.
How should I do this?
The ShortcutKey sample application of the WPF Application Framework (WAF) shows how to implement this scenario. You will find two versions of this download:
- .NET 3.5 - uses some lines of code behind.
- .NET 4 - Uses Binding.
精彩评论