ModifierKeys ModifierKeys ModifierKeys ModifierKeys Enum

定義

指定一組輔助按鍵 (Modifier Key)。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建立關聯的KeyGesture使用RoutedCommandThe 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 Attribute UsageXAML Attribute Usage

<object property="oneOrMoreModifierKeys"/>  

XAML 值XAML Values

oneOrMoreModifierKeysoneOrMoreModifierKeys
一或多個所定義的輔助按鍵ModifierKeys列舉型別,以"+"字元分隔。One or more modifier keys, defined by the ModifierKeys enumeration, delimited with a "+" character.

適用於

另請參閱