关于WPF 的快捷键

Posted on 2013-08-09 14:34  xiaomaogong  阅读(440)  评论(0)    收藏  举报

首先可以以在任意的UIElement中的InputBindings 添加KeyBinding或者其他的mouseBinding, 如下

<UserControl.InputBindings>
        <KeyBinding Command="{Binding NavCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" Key="D1" Modifiers="Control" CommandParameter="{Binding ElementName=curveSummaryGroup}"/>
        <KeyBinding Command="{Binding NavCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" Key="D2" Modifiers="Control" CommandParameter="{Binding ElementName=curveHistoryGroup}"/>
    </UserControl.InputBindings>

其中

Gesture = key + Modifiers,可以只用genstrure或者key + Modifiers,但不要一起用会造成冲突

 

 

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3