Multiple Keybinding to a single command

2019-07-16 17:03发布

My window has just a listview. This facilitates the users to incremental search the db. Since the design does not have a textbox, i've to globally handle the keys. I think it could be achieved by keybinding. But how can i handle all the keys and associate it to a single command.

Also suggest me other methods if any.

P.S.: I want this in xaml

1条回答
SAY GOODBYE
2楼-- · 2019-07-16 17:30

I would use an EventToCommand binding the KeyDown event to a command on the ViewModel. You can set PassEventArgsToCommand to true, and use a RelayCommand to find out what key as pressed.

All these objects are available in the MVVM Light Toolkit

http://www.galasoft.ch/mvvm/getstarted

Cheers, Laurent

查看更多
登录 后发表回答