다음을 통해 공유


KeyGesture 클래스

정의

명령을 호출하는 데 사용할 수 있는 키보드 조합을 정의합니다.

public ref class KeyGesture : System::Windows::Input::InputGesture
[System.ComponentModel.TypeConverter(typeof(System.Windows.Input.KeyGestureConverter))]
public class KeyGesture : System.Windows.Input.InputGesture
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Input.KeyGestureConverter))>]
type KeyGesture = class
    inherit InputGesture
Public Class KeyGesture
Inherits InputGesture
상속
KeyGesture
특성

예제

다음 예제에서는 명령을 usingKeyBindingKeyGesture 바인딩 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)

다음 예제에서는 XAML에서 사용하는 KeyGesture 방법을 보여줍니다. XAML 사용은 요소를 직접 선언 <KeyGesture> 하지 않습니다. 공용 매개 변수가 없는 생성자를 노출하지 않으므로 해당 개체 요소 사용은 불가능 KeyGesture 합니다. 대신 XAML 사용은 typeconverter 동작을 사용하여 전체 KeyGesture 인라인을 Gesture 특성 값으로 선언합니다.

<Window.InputBindings>
  <KeyBinding Command="ApplicationCommands.Open"
              Gesture="CTRL+R" />
</Window.InputBindings>

설명

대부분의 경우 A는 KeyGesture 하나 이상 ModifierKeys과 연결되어야 합니다. 이 규칙의 예외는 함수 키와 숫자 키패드 키이며, 이는 자체적으로 유효 KeyGesture 할 수 있습니다. 예를 들어 F12 키만 사용하여 만들 KeyGesture 수 있지만 X 키를 사용하려면 한정자 키 KeyGesture 와 페어링해야 합니다.

KeyBinding 경우 명령이 KeyGesture 호출되도록 a를 ICommand사용하여 에 바인딩할 KeyGesture 수 있습니다.

XAML 사용의 경우 KeyGesture 제스처가 표준 키와 한정자 키를 모두 나타내는 경우 XAML에서 일반적으로 설정되는 속성입니다 Gesture. 속성을 함수 키 또는 한정자 키 조합으로 설정할 Gesture 수도 있습니다. 그러나 의도한 명령 바인딩이 한정자가 없는 함수 키이거나 Modifiers 의도한 명령 바인딩이 한정자 키에만 사용되는 경우 속성을 설정하는 Key 것이 더 일반적입니다.

XAML 특성 사용

<object property="oneOrMoreModifierKeys+key"/>
- or -
<object property="functionKey"/>

XAML 값

functionKey Key

함수 키(F1-12) 또는 숫자 키패드 키 중 하나여야 하는 단일 키 값입니다.

oneOrMoreModifierKeys 열거형으로 ModifierKeys 정의된 하나 이상의 한정자 키는 "+" 문자로 구분됩니다.

key Key

단일 키 값입니다.

생성자

Name Description
KeyGesture(Key, ModifierKeys, String)

지정된 KeyModifierKeys문자열을 사용하여 클래스의 KeyGesture 새 인스턴스를 초기화하고 문자열을 표시합니다.

KeyGesture(Key, ModifierKeys)

지정된 클래스와 .를 사용하여 클래스의 KeyGesture 새 인스턴스를 Key 초기화합니다 ModifierKeys.

KeyGesture(Key)

지정된 클래스를 사용하여 클래스의 KeyGesture 새 인스턴스를 초기화합니다 Key.

속성

Name Description
DisplayString

KeyGesture문자열의 표현을 가져옵니다.

Key

KeyGesture키와 연결된 키를 가져옵니다.

Modifiers

KeyGesture키와 연결된 한정자 키를 가져옵니다.

메서드

Name Description
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetDisplayStringForCulture(CultureInfo)

를 표시하는 데 사용할 수 있는 문자열을 반환합니다 KeyGesture.

GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
Matches(Object, InputEventArgs)

지정된 InputEventArgs 개체와 연결된 입력과 일치하는지 여부를 KeyGesture 확인합니다.

MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보