KeyGesture Konstruktorer

Definition

Initierar en ny instans av KeyGesture klassen.

Överlagringar

Name Description
KeyGesture(Key)

Initierar en ny instans av KeyGesture klassen med angiven Key.

KeyGesture(Key, ModifierKeys)

Initierar en ny instans av KeyGesture klassen med angivet Key och ModifierKeys.

KeyGesture(Key, ModifierKeys, String)

Initierar en ny instans av KeyGesture klassen med angiven Key, ModifierKeysoch visningssträng.

KeyGesture(Key)

Initierar en ny instans av KeyGesture klassen med angiven Key.

public:
 KeyGesture(System::Windows::Input::Key key);
public KeyGesture(System.Windows.Input.Key key);
new System.Windows.Input.KeyGesture : System.Windows.Input.Key -> System.Windows.Input.KeyGesture
Public Sub New (key As Key)

Parametrar

key
Key

Nyckeln som är associerad med den här gesten.

Undantag

key är inte ett giltigt Key.

key är inte ett giltigt KeyGesture.

Exempel

I följande exempel visas hur du använder den här konstruktorn för att skapa en KeyGesture och associera den med en KeyBinding. KeyBinding Läggs sedan till i för InputBindingCollection en Window.

KeyGesture OpenCmdKeyGesture = new KeyGesture(Key.F12);
KeyBinding OpenKeyBinding = new KeyBinding(
    ApplicationCommands.Open,
    OpenCmdKeyGesture);

this.InputBindings.Add(OpenKeyBinding);
Dim OpenCmdKeyGesture As New KeyGesture(Key.F12)
Dim OpenKeyBinding As New KeyBinding(ApplicationCommands.Open, OpenCmdKeyGesture)

Me.InputBindings.Add(OpenKeyBinding)

Kommentarer

I de flesta fall måste en KeyGesture associeras med en eller flera ModifierKeys. Undantagen till den här regeln är funktionsnycklarna och de numeriska knappsatsnycklarna, som kan vara giltiga KeyGesture själva.

Se även

Gäller för

KeyGesture(Key, ModifierKeys)

Initierar en ny instans av KeyGesture klassen med angivet Key och ModifierKeys.

public:
 KeyGesture(System::Windows::Input::Key key, System::Windows::Input::ModifierKeys modifiers);
public KeyGesture(System.Windows.Input.Key key, System.Windows.Input.ModifierKeys modifiers);
new System.Windows.Input.KeyGesture : System.Windows.Input.Key * System.Windows.Input.ModifierKeys -> System.Windows.Input.KeyGesture
Public Sub New (key As Key, modifiers As ModifierKeys)

Parametrar

key
Key

Nyckeln som är associerad med gesten.

modifiers
ModifierKeys

De modifierarnycklar som är associerade med gesten.

Undantag

modifiers är inte giltigt ModifierKeys

-eller-

key är inte ett giltigt Key.

key och modifiers bildar inte ett giltigt KeyGesture.

Exempel

I följande exempel visas hur du använder den här konstruktorn för att skapa en KeyGesture och associera den med en KeyBinding. KeyBinding Läggs sedan till i för InputBindingCollection en Window.

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

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

this.InputBindings.Add(CloseKeyBinding);
Dim CloseCmdKeyGesture As New KeyGesture(Key.L, ModifierKeys.Alt)

Dim CloseKeyBinding As New KeyBinding(ApplicationCommands.Close, CloseCmdKeyGesture)

Me.InputBindings.Add(CloseKeyBinding)

Kommentarer

I de flesta fall måste en KeyGesture associeras med en eller flera ModifierKeys. Undantagen till den här regeln är funktionsnycklarna och de numeriska knappsatsnycklarna, som kan vara giltiga KeyGesture själva.

Se även

Gäller för

KeyGesture(Key, ModifierKeys, String)

Initierar en ny instans av KeyGesture klassen med angiven Key, ModifierKeysoch visningssträng.

public:
 KeyGesture(System::Windows::Input::Key key, System::Windows::Input::ModifierKeys modifiers, System::String ^ displayString);
public KeyGesture(System.Windows.Input.Key key, System.Windows.Input.ModifierKeys modifiers, string displayString);
new System.Windows.Input.KeyGesture : System.Windows.Input.Key * System.Windows.Input.ModifierKeys * string -> System.Windows.Input.KeyGesture
Public Sub New (key As Key, modifiers As ModifierKeys, displayString As String)

Parametrar

key
Key

Nyckeln som är associerad med gesten.

modifiers
ModifierKeys

De modifierarnycklar som är associerade med gesten.

displayString
String

En strängrepresentation av KeyGesture.

Undantag

modifiers är inte giltigt ModifierKeys

-eller-

key är inte ett giltigt Key.

displayString är null.

key och modifiers bildar inte ett giltigt KeyGesture.

Kommentarer

Egenskapen DisplayString är inställd på parametern displayString .

Se även

Gäller för