开发者

Assign a shortcut key to a command in a ViewModel in WPF [duplicate]

This question already has answers here: Closed 12 years ago.

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:

  1. .NET 3.5 - uses some lines of code behind.
  2. .NET 4 - Uses Binding.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜