首先可以以在任意的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,但不要一起用会造成冲突