【问题标题】:Assigning more than one Modifier Keys to a Key Gesture SHIFT + F not supported不支持将多个修改键分配给按键手势 SHIFT + F
【发布时间】:2011-07-28 08:43:40
【问题描述】:

我有以下代码:

MyPlayPause.InputGestures.Add(new KeyGesture(Key.P, ModifierKeys.Control));

我需要添加另一个手势,所以我可以使用 SHIFT + CTRL + P 但是当我添加以下选项时它会中断:

MyPlayPause.InputGestures.Add(new KeyGesture(Key.P, ModifierKeys.Control));

换档选项。我收到此错误:'Shift+F' key and modifier combination is not supported for KeyGesture.

知道为什么吗?我需要复制媒体播放器快进按钮的功能。

【问题讨论】:

标签: c# wpf keyboard-shortcuts


【解决方案1】:

ModifierKeys 枚举被标记为[FlagsAttribute],所以你可以这样做:

ModifierKeys.Control | ModifierKeys.Shift

所以:

MyPlayPause.InputGestures.Add(new KeyGesture(Key.P, ModifierKeys.Control |  ModifierKeys.Shift));

【讨论】:

  • 是的,但是如果我使用 'Key.D0' 和 ModifierKeys.Control | ModifierKeys.None 将数字键绑定到命令,则该快捷方式仅在按下 Control 时有效,这应该是 @987654326 @ AND OR '控制`。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-02
  • 1970-01-01
  • 1970-01-01
  • 2016-08-02
  • 2023-03-21
  • 2011-01-12
  • 1970-01-01
相关资源
最近更新 更多