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
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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003