如何在WPF MVVM模式中创建快捷键 [英] How to Create Short Cut Keys in WPF MVVM pattern

查看:95
本文介绍了如何在WPF MVVM模式中创建快捷键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能告诉我在MVVM模式下用WPF创建短剪切键的一步一步过程吗?

解决方案

你必须在WPF中使用命令。 />


以下是一些链接:



http://stackoverflow.com/questions/2382916/binding-a-wpf-shortcut-key-to- a-command-in-the-viewmodel [ ^ ]



HTTP:// WWW。 progware.org/Blog/post/Going-from-Model-View-Presenter-to-MV-VM-with-WPF-Commands-%28Part-2-Commands-with-MVP%29.aspx [< a href =http://www.progware.org/Blog/post/Going-from-Model-View-Presenter-to-MV-VM-with-WP F-Commands-%28Part-2-Commands-with-MVP%29.aspxtarget =_ blanktitle =New Window> ^ ]



http://codingcontext.wordpress.com/2008/12/10/commandbindings- in-mvvm / [ ^ ]



http://social.msdn.microsoft.com/Forums/en/wpf/thread/4a852d58-9397-41e7-bee1-fc7c63d39da7 [ ^ ]



祝您好运!


如果您正在谈论菜单选项,请参阅这里 [ ^ ]。

同样的方法也可以应用于其他控件。


在Xaml中,

< window> 
< window.inputbindings>
< keybinding command = {Binding< CommandName>} key = < Key> />
< / window.inputbindings >
< / window >


Can you tell me step by step process in creating short Cut keys in WPF in MVVM pattern?

解决方案

Well you have to use Commands in WPF.

Here are a few links:

http://stackoverflow.com/questions/2382916/binding-a-wpf-shortcut-key-to-a-command-in-the-viewmodel[^]

http://www.progware.org/Blog/post/Going-from-Model-View-Presenter-to-MV-VM-with-WPF-Commands-%28Part-2-Commands-with-MVP%29.aspx[^]

http://codingcontext.wordpress.com/2008/12/10/commandbindings-in-mvvm/[^]

http://social.msdn.microsoft.com/Forums/en/wpf/thread/4a852d58-9397-41e7-bee1-fc7c63d39da7[^]

Good luck!


If you are talking about menu options, see here[^].
The same approach can be applied to other controls as well.


In Xaml,

<window>
<window.inputbindings>
<keybinding command="{Binding <CommandName>}" key="<Key>" />
</window.inputbindings>
</window>


这篇关于如何在WPF MVVM模式中创建快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆