所以我有这个KeyBinding
:
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+Alt+S" Command="{Binding TestCommand}"
HotkeyManager.RegisterGlobalHotkey="True" />
</Window.InputBindings>
而且我的应用程序有几个ToggeButtons
,用户需要指定快捷方式ans,我希望能够从后面的代码中更改此快捷方式:
Gesture="Ctrl+Alt+S"
有什么建议吗?
创建KeyGesture
。 ModifierKeys
是标志enum
:
KeyBinding binding = new KeyBinding()
{
Gesture = new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Alt)
};