ModifierKeys 枚举

定义

指定修改键集。Specifies the set of modifier keys.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class ModifierKeys
[System.ComponentModel.TypeConverter(typeof(System.Windows.Input.ModifierKeysConverter))]
[System.Flags]
public enum ModifierKeys
type ModifierKeys = 
Public Enum ModifierKeys
继承
ModifierKeys
属性

字段

Alt 1

Alt 键。The ALT key.

Control 2

CTRL 键。The CTRL key.

None 0

没有按下任何修饰符。No modifiers are pressed.

Shift 4

Shift 键。The SHIFT key.

Windows 8

Windows 徽标键。The Windows logo key.

示例

下面的示例演示如何创建一个将 KeyGestureRoutedCommand相关联的 KeyBindingThe following example shows how to create a KeyBinding that associates a KeyGesture with a RoutedCommand. KeyBinding 使用 ModifierKeys 枚举来指定该笔势的修改键。The KeyBinding uses the ModifierKeys enumeration to specify the modifier key of the gesture.

<Window.InputBindings>
  <KeyBinding Command="ApplicationCommands.Open"
              Gesture="CTRL+R" />
</Window.InputBindings>
// Creating a KeyBinding between the Open command and Ctrl-R
KeyBinding OpenCmdKeyBinding = new KeyBinding(
    ApplicationCommands.Open, 
    Key.R, 
    ModifierKeys.Control);

this.InputBindings.Add(OpenCmdKeyBinding);
' Creating a KeyBinding between the Open command and Ctrl-R
Dim OpenCmdKeyBinding As New KeyBinding(ApplicationCommands.Open, Key.R, ModifierKeys.Control)

Me.InputBindings.Add(OpenCmdKeyBinding)

注解

Keyboard 类的 Modifiers 属性是当前按下的修改键的集合。The Modifiers property on the Keyboard class is the set of the modifier keys that are currently pressed.

Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 中使用 ModifierKeys 枚举的某些 Api 是 KeyboardKeyBindingKeyGestureMouseGesture 类的 Modifiers 属性。Some APIs in Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) that make use of the ModifierKeys enumeration are the Modifiers properties on the Keyboard, KeyBinding, KeyGesture, and MouseGesture classes.

XAML 属性用法XAML Attribute Usage

<object property="oneOrMoreModifierKeys"/>  

XAML 值XAML Values

oneOrMoreModifierKeysoneOrMoreModifierKeys
ModifierKeys 枚举定义的一个或多个修改键,用 "+" 字符分隔。One or more modifier keys, defined by the ModifierKeys enumeration, delimited with a "+" character.

适用于

另请参阅