代码之家  ›  专栏  ›  技术社区  ›  Grokys

WPF键手势.绑定非字母数字键

  •  8
  • Grokys  · 技术社区  · 14 年前

    应该很简单,但我不知道怎么做。我想用WPF4绑定 + - 缩小 + =

        <KeyBinding Command="{Binding Content.ZoomInCommand}" Gesture="Ctrl+="/>
        <KeyBinding Command="{Binding Content.ZoomOutCommand}" Gesture="Ctrl+-"/>
    

    然而,我得到了错误:在 Ctrl键 + = :

    有什么想法吗?

    2 回复  |  直到 13 年前
        1
  •  8
  •   Jasper wontondon    13 年前

    好吧-事实证明 = Key -枚举-没有 相等 等号 = 班次 第0页 在丹麦键盘上),并使用该键序列。

    <KeyBinding Command="{Binding Content.ZoomInCommand}" Gesture="Ctrl+Shift+D0"/>
    

    OemPlus 键-但您可以通过控制台写入 e.Key

    编辑2:the - 关键是 OemMinus

        2
  •  8
  •   Knasterbax    13 年前

    对具有 (可能还有其他一些国家):

    numpad键“+”和“-”是“加法”和“减法”

    普通键“+”和“-”是“OemPlus”和“OemMinus”

    所以呢

    <KeyBinding Gesture = "OemPlus" Command="myCommand" />