Triggering Silverlight Prism command with a keyboard shortcut(使用键盘快捷键触发 Silverlight Prism 命令)
问题描述
有人知道是否可以使用快捷方式触发棱镜命令吗?我的意思是我希望能够以声明方式定义命令与键盘快捷键的绑定,例如 但我认为它没有答案我的.
我已经创建了这样的手势触发器.我想和你们分享.基本上,它是 System.Windows.Interactivity
触发器,可以解析表示为字符串的手势.用法和在 ClientUI 中一样简单:
<UserControl><i:Interaction.Triggers><行为:KeystrokeCommandTrigger Command="{Binding SaveChangesCommand}" Gesture="Ctrl+Shift+S"/><行为:KeystrokeCommandTrigger Command="{Binding RejectChangesCommand}" Gesture="Ctrl+Shift+R"/><行为:KeystrokeCommandTrigger Command="{Binding NewItemCommand}" Gesture="Ins"/><行为:KeystrokeCommandTrigger Command="{Binding DeleteSelectedItemCommand}" Gesture="Del"/><行为:KeystrokeCommandTrigger Command="{Binding UploadSomethingCommand}" Gesture="Ctrl+Shift+U"/></i:Interaction.Triggers></用户控制>
代码在pastie上.
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.
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>
The code is on pastie.
这篇关于使用键盘快捷键触发 Silverlight Prism 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用键盘快捷键触发 Silverlight Prism 命令


- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 输入按键事件处理程序 2022-01-01