ModifierKeys 列舉

定義

指定一組輔助按鍵 (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
繼承
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 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.

適用於

另請參閱