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.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetDisplayStringForCulture||Returns a string that can be used to display the .|
|GetHashCode||Serves as the default hash function. (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.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.