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 命令


基础教程推荐
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- rabbitmq 的 REST API 2022-01-01