WPF MVVM应用程序中的键盘事件? [英] Keyboard events in a WPF MVVM application?
本文介绍了WPF MVVM应用程序中的键盘事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不使用代码隐藏的情况下处理Keyboard.KeyDown事件?我们正在尝试使用MVVM模式,并避免在代码隐藏文件中编写事件处理程序.
How can I handle the Keyboard.KeyDown event without using code-behind? We are trying to use the MVVM pattern and avoid writing an event handler in code-behind file.
推荐答案
有点晚了,但是可以了.
A little late, but here goes.
Microsoft的WPF团队最近发布了 WPF MVVM的早期版本工具包 .在其中,您将找到一个名为CommandReference的类,该类可以处理诸如键盘绑定之类的事情.查看他们的WPF MVVM模板以了解其工作原理.
Microsoft's WPF Team recently released an early version of their WPF MVVM Toolkit . In it, you'll find a class called CommandReference that can handle things like keybindings. Look at their WPF MVVM template to see how it works.
这篇关于WPF MVVM应用程序中的键盘事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文