Defines a keyboard combination that can be used to invoke a command.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Thetype exposes the following members.
|KeyGesture(Key)||Initializes a new instance of the class with the specified Key.|
|KeyGesture(Key, ModifierKeys)||Initializes a new instance of the class with the specified Key and ModifierKeys.|
|KeyGesture(Key, ModifierKeys, String)||Initializes a new instance of the class with the specified Key, ModifierKeys, and display string.|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|GetDisplayStringForCulture||Returns a string that can be used to display the .|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|Matches||Determines whether this matches the input associated with the specified InputEventArgs object. (Overrides InputGesture.Matches(Object, InputEventArgs).)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
In most cases, a must be associated with one or more ModifierKeys. The exceptions to this rule are the function keys and the numeric keypad keys, which can be a valid by themselves. For example, you can create a by using only the F12 key, but to use the X key in a it must be paired with a modifier key.
In general, you can
For XAML usages, the property that is generally set in XAML is Gesture, in cases where the gesture represents both a standard key and a modifier key. You can also set the Gesture property to be just a function key, or just a modifier key combination. However, it is more common to set the Key property if the intended command binding is a function key with no modifiers, or Modifiers if the intended command binding is for modifier keys only.
The following example shows how to use in XAML. Note that the XAML usage does not directly declare a <KeyGesture> element. That object element usage is not possible because does not expose a public default constructor. Instead, the XAML usage uses the typeconverter behavior to declare an entire inline as the Gesture attribute value.