InputBinding.Gesture Właściwość

Definicja

Pobiera lub ustawia InputGesture skojarzone z tym powiązaniem wejściowym.

public:
 virtual property System::Windows::Input::InputGesture ^ Gesture { System::Windows::Input::InputGesture ^ get(); void set(System::Windows::Input::InputGesture ^ value); };
public virtual System.Windows.Input.InputGesture Gesture { get; [System.Security.SecurityCritical] set; }
public virtual System.Windows.Input.InputGesture Gesture { get; set; }
[<set: System.Security.SecurityCritical>]
member this.Gesture : System.Windows.Input.InputGesture with get, set
member this.Gesture : System.Windows.Input.InputGesture with get, set
Public Overridable Property Gesture As InputGesture

Wartość właściwości

Skojarzony gest. Wartość domyślna to null.

Atrybuty

Przykłady

W poniższym przykładzie pokazano, jak użyć klasy KeyBinding , aby powiązać element z KeyGesture elementem RoutedCommand. Po naciśnięciu Close klawiszy KeyGesture ALT+L polecenie jest wywoływane.

<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);
Dim CloseCmdKeyGesture As New KeyGesture(Key.L, ModifierKeys.Alt)

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

Me.InputBindings.Add(CloseKeyBinding)

Uwagi

Gest wejściowy to akcja, która wywołuje polecenie. Przykłady gestów wejściowych w WPF to KeyGesture i MouseGesture. A KeyGesture jest kombinacją obiektu Key i zestawu ModifierKeys. A MouseGesture jest kombinacją obiektu MouseAction i zestawu ModifierKeys.

Sama InputBinding klasa nie obsługuje użycia języka XAML, ponieważ nie uwidacznia publicznego konstruktora bez parametrów (istnieje konstruktor bez parametrów, ale jest chroniony). Jednak klasy pochodne mogą uwidaczniać publiczny konstruktor i w ten sposób mogą ustawiać właściwości dziedziczone z InputBinding użyciem XAML. Dwie istniejące InputBinding klasy pochodne, które mogą być tworzone w języku XAML i mogą ustawiać właściwości w języku XAML, to KeyBinding i MouseBinding.

Użycie atrybutu języka XAML

<KeyBindingGesture=""KeyGesture/>

-lub-

<MouseBindingGesture=""MouseGesture/>

-lub-

<inputBindingDerivedClassGesture=""InputGesture/>

Użycie elementu właściwości języka XAML

<inputBindingDerivedClass>  
  <inputBindingDerivedClass.Gesture>  
    <inputGestureImplementation/>  
  </inputBindingDerivedClass.Gesture>  
</inputBindingDerivedClass>  

Wartości XAML

inputBindingDerivedClass
Klasa pochodna InputBinding , która obsługuje składnię elementu obiektu, taką jak KeyBinding lub MouseBinding. Zobacz uwagi.

inputGestureImplementation
Niestandardowa klasa pochodna InputGesture , która obsługuje składnię elementu obiektu.

Dotyczy

Zobacz też