ModifierKeys 枚举
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定修改键集。
此枚举支持其成员值的按位组合。
public enum class ModifierKeys
C#
[System.ComponentModel.TypeConverter(typeof(System.Windows.Input.ModifierKeysConverter))]
[System.Flags]
public enum ModifierKeys
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Input.ModifierKeysConverter))>]
[<System.Flags>]
type ModifierKeys =
Public Enum ModifierKeys
- 继承
- 属性
名称 | 值 | 说明 |
---|---|---|
Alt | 1 | Alt 键。 |
Control | 2 | CTRL 键。 |
None | 0 | 没有按下任何修饰符。 |
Shift | 4 | Shift 键。 |
Windows | 8 | Windows 徽标键。 |
以下示例演示如何创建将 KeyBinding 与 RoutedCommand关联的 KeyGesture 。 使用 KeyBindingModifierKeys 枚举来指定手势的修饰键。
XAML
<Window.InputBindings>
<KeyBinding Command="ApplicationCommands.Open"
Gesture="CTRL+R" />
</Window.InputBindings>
C#
// 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 属性是当前按下的修饰键集。
使用 枚举Windows Presentation Foundation (WPF) ModifierKeys 中的一些 API 是 Modifiers 、KeyBinding、 KeyGesture和 MouseGesture 类的属性Keyboard。
<object property="oneOrMoreModifierKeys"/>
oneOrMoreModifierKeys
一个或多个修饰键,由 ModifierKeys 枚举定义,用“+”字符分隔。
产品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |