Multiple Keybinding to a single command

若如初见. 提交于 2019-12-11 00:39:40

问题


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:


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



来源:https://stackoverflow.com/questions/2660069/multiple-keybinding-to-a-single-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!