KeyBinding.Key Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the Key of the KeyGesture associated with this KeyBinding.
public:
property System::Windows::Input::Key Key { System::Windows::Input::Key get(); void set(System::Windows::Input::Key value); };
public System.Windows.Input.Key Key { get; set; }
member this.Key : System.Windows.Input.Key with get, set
Public Property Key As Key
Property Value
The key part of the KeyGesture. The default value is None.
Remarks
With the exception of the function keys and the numeric keypad keys, a KeyGesture must contain a Key and one or more ModifierKeys.
When defining a KeyBinding in Extensible Application Markup Language (XAML) there are two ways to specify the KeyGesture. The first way to establish a KeyBinding in XAML 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". The second way is to define the Key attribute and the Modifiers attributes of the KeyBinding element. Both ways of setting the KeyGesture are equivalent and modify the same underlying object, but there will be a conflict if both are used. In 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. 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. In general, it is recommended that you use only the Gesture attribute from XAML; this will avoid ambiguity, provides the most streamlined syntax, and provides the most straightforward representation for serialization.