KeyBinding.Modifiers 属性

定义

获取或设置与此 ModifierKeys 关联的 KeyGestureKeyBindingGets or sets the ModifierKeys of the KeyGesture associated with this KeyBinding.

public:
 property System::Windows::Input::ModifierKeys Modifiers { System::Windows::Input::ModifierKeys get(); void set(System::Windows::Input::ModifierKeys value); };
public System.Windows.Input.ModifierKeys Modifiers { get; set; }
member this.Modifiers : System.Windows.Input.ModifierKeys with get, set
Public Property Modifiers As ModifierKeys

属性值

ModifierKeys

KeyGesture 的修改键。The modifier keys of the KeyGesture. 默认值是 NoneThe default value is None.

注解

除了函数键和数字键盘键以外,KeyGesture 必须包含 Key 和一个或多个 ModifierKeysWith the exception of the function keys and the numeric keypad keys, a KeyGesture must contain a Key and one or more ModifierKeys.

可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) 中定义 KeyBinding 时,有两种方法可指定 KeyGestureWhen defining a KeyBinding in 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) there are two ways to specify the KeyGesture. XAMLXAML 中建立 KeyBinding 的第一种方法是定义 KeyBinding 元素的 Gesture 属性,这将启用语法以将键和修饰符指定为单个字符串,例如 "CTRL + P"。The first way to establish a KeyBinding in XAMLXAML is to define the Gesture attribute of the KeyBinding element, which enables a syntax to specify keys and modifiers as a single string, for example "CTRL+P". 第二种方法是定义 Key 属性和 KeyBinding 元素的 Modifiers 属性。The second way is to define the Key attribute and the Modifiers attributes of the KeyBinding element. 设置 KeyGesture 的两种方法都是等效的,并且修改相同的基础对象,但如果两者都使用,则会发生冲突。Both ways of setting the KeyGesture are equivalent and modify the same underlying object, but there will be a conflict if both are used. 如果已设置 KeyModifiersGesture 属性,则最后定义的属性将用于该 KeyGestureIn the case when the Key, Modifiers, and the Gesture attributes are all set, the attribute which is defined last will be used for the KeyGesture. 在某些情况下,您可能会遇到这样的情况:例如,Key 集最后将只覆盖前面的手势的关键组件,但使该笔势的修饰符保持不变。You can potentially have situations where for example a Key set last will overwrite just the Key component of a preceding Gesture but leave the Gesture's modifiers the same. 通常,建议仅使用 XAMLXAML中的 Gesture 属性;这将避免多义性,提供最简单的语法,并提供最简单的序列化表示形式。In general, it is recommended that you use only the Gesture attribute from XAMLXAML; this will avoid ambiguity, provides the most streamlined syntax, and provides the most straightforward representation for serialization.

XAML 特性用法XAML Attribute Usage

<object Modifiers="oneOrMoreModifierKeys"/>  
  

XAML 值XAML Values

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

适用于

另请参阅