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.
推荐答案
有点晚了,但是来了.
微软的 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屋!
查看全文