wpf - 如何从后面的代码在 XAML 中添加手势
问题描述
所以我有这个KeyBinding
:
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+Alt+S" Command="{Binding TestCommand}"
HotkeyManager.RegisterGlobalHotkey="True" />
</Window.InputBindings>
而且我的应用程序有几个ToggeButtons
用户需要指定快捷方式,并且我希望能够从后面的代码中更改它:
Gesture="Ctrl+Alt+S"
有什么建议么 ?
解决方案
创建一个KeyGesture
. 这ModifierKeys
是一个标志enum
:
KeyBinding binding = new KeyBinding()
{
Gesture = new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Alt)
};
推荐阅读
- django - Django工具栏:不显示过滤器大于的查询结果
- powershell - SCCM - 通过其任务序列检测计算机何时完全完成安装的 Surefire 方法
- r - Applying function to each group and column of R dataframe
- javascript - 使用 Javascript getBoundingClientRect 将项目捕捉到网格
- angular - Jasmine / Karma error as cannot read property of undefined
- git - Will removing a file from Git history also remove its replacement?
- c# - 适用于 OneDrive 的 Microsoft Graph API 响应服务不可用
- angular - 未捕获的错误:找不到模块“tslib”
- javascript - 从标签中获取内容并将其保存在 vue 中的变量中的最有效方法
- firebase - “String”类型的值没有成员“uid”