ModifierKeys ModifierKeys ModifierKeys ModifierKeys Enum

定义

指定修改键集。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
继承
属性

字段

Alt Alt Alt Alt 1

Alt 键。The ALT key.

Control Control Control Control 2

CTRL 键。The CTRL key.

None None None None 0

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

Shift Shift Shift Shift 4

Shift 键。The SHIFT key.

Windows Windows Windows Windows 8

Windows 徽标键。The Windows logo key.

示例

下面的示例演示如何创建KeyBinding将关联KeyGestureRoutedCommandThe 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)

注解

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

某些APIAPIsWindows Presentation Foundation (WPF)Windows Presentation Foundation (WPF),请使用ModifierKeys枚举都Modifiers上的属性KeyboardKeyBindingKeyGesture,和MouseGesture类。Some APIAPIs 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.

适用于

另请参阅