触发的Silverlight棱镜命令与键盘快捷键 [英] Triggering Silverlight Prism command with a keyboard shortcut

查看:186
本文介绍了触发的Silverlight棱镜命令与键盘快捷键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道一个人是否可以触发一个快捷棱镜命令?我的意思是我希望能够以声明的方式来定义命令绑定键盘快捷键,像的 ClientUI 做:

Does anybody know whether one can trigger prism command with a shortcut? What I mean is I want to be able to define binding of a command to keyboard shortcut in declarative manner, like ClientUI does:

有什么开源库的目的是什么?或者,也许代码示例?

Are there any opensource libraries for that purpose? Or maybe code samples?

我发现的这个问题,但我不认为它回答我的。

I found this question but I don't think that it answers mine.

推荐答案

我已经创造了这样的姿态触发。我想与你们分享。基本上,它是 System.Windows.Interactivity 触发可解析字符串表示的手势。用法是在ClientUI简单:

I've created such gesture trigger. And I'd like to share it with you guys. Basically, it is System.Windows.Interactivity trigger which can parse gestures represented as strings. Usage is as simple as in ClientUI:

<UserControl>
    <i:Interaction.Triggers>
        <behaviors:KeystrokeCommandTrigger Command="{Binding SaveChangesCommand}" Gesture="Ctrl+Shift+S" />
        <behaviors:KeystrokeCommandTrigger Command="{Binding RejectChangesCommand}" Gesture="Ctrl+Shift+R" />
        <behaviors:KeystrokeCommandTrigger Command="{Binding NewItemCommand}" Gesture="Ins" />
        <behaviors:KeystrokeCommandTrigger Command="{Binding DeleteSelectedItemCommand}" Gesture="Del" />
        <behaviors:KeystrokeCommandTrigger Command="{Binding UploadSomethingCommand}" Gesture="Ctrl+Shift+U" />
    </i:Interaction.Triggers>
</UserControl>



中的代码是的 pastie

这篇关于触发的Silverlight棱镜命令与键盘快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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