(0) exportieren Drucken
Alle erweitern

KeyGesture-Klasse

Defines a keyboard combination that can be used to invoke a command.

Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)
XML-Namespaces:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[TypeConverterAttribute(typeof(KeyGestureConverter))] 
public class KeyGesture : InputGesture
/** @attribute TypeConverterAttribute(System.Windows.Input.KeyGestureConverter) */ 
public class KeyGesture extends InputGesture
TypeConverterAttribute(System.Windows.Input.KeyGestureConverter) 
public class KeyGesture extends InputGesture
<object property="Key"/>
- or -
<object property="oneOrMoreModifierKeys"/>
- or -
<object property="Key+oneOrMoreModifierKeys"/>

 Key   Key  A single key.  For more information, see the Key property.  oneOrMoreModifierKeys  One or more modifier keys, defined by the ModifierKeys enumeration, delimited with a "+" character.  For more information, see the Modifiers property. 

In most cases, a KeyGesture 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 KeyGesture by themselves. For example, you can create a KeyGesture by using only the F12 key, but to use the X key in a KeyGesture it must be paired with a modifier key.

You can use a KeyBinding to bind a KeyGesture to an ICommand, so that the command is invoked when the KeyGesture occurs.

The following example shows how to bind the Close command to a KeyGesture using a KeyBinding.

<KeyBinding Modifiers="Alt"
            Key="L"
            Command="ApplicationCommands.Close" />

KeyGesture CloseCmdKeyGesture = new KeyGesture(
    Key.L, ModifierKeys.Alt);

KeyBinding CloseKeyBinding = new KeyBinding(
    ApplicationCommands.Close, CloseCmdKeyGesture);

this.InputBindings.Add(CloseKeyBinding);

System.Object
   System.Windows.Input.InputGesture
    System.Windows.Input.KeyGesture

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Microsoft .NET Framework 3.0 wird unter Windows Vista, Microsoft Windows XP SP2 und Windows Server 2003 SP1 unterstützt.

.NET Framework

Unterstützt in: 3.0
Anzeigen:
© 2014 Microsoft