KeyBinding.Key 屬性

定義

取得或設定與這個 Key 關聯 KeyGestureKeyBinding

public:
 property System::Windows::Input::Key Key { System::Windows::Input::Key get(); void set(System::Windows::Input::Key value); };
public System.Windows.Input.Key Key { get; set; }
member this.Key : System.Windows.Input.Key with get, set
Public Property Key As Key

屬性值

Key

KeyGesture 的按鍵部分。 預設值是 None

備註

除了函式索引鍵和數值鍵盤按鍵之外,必須 KeyGesture 包含 Key 和一或多個 ModifierKeys

在 Extensible Application Markup Language (XAML 中定義 KeyBinding 時,) 有兩種方式可以指定 KeyGesture。 在 XAML 中建立 的第一 KeyBinding 種方式是定義 Gesture 項目的 屬性 KeyBinding ,這可讓語法將索引鍵和修飾詞指定為單一字串,例如 “CTRL+P”。 第二種方式是定義 Key 屬性和 Modifiers 元素的屬性 KeyBinding 。 這兩種設定 KeyGesture 方式都是相等的,並修改相同的基礎物件,但如果兩者都使用,就會發生衝突。 Key在、 ModifiersGesture 屬性所有設定的情況下,最後定義的屬性會用於 KeyGesture。 您可能有一個情況,例如,最後一個 Key 集合只會覆寫先前的 Gesture 的 Key 元件,但讓筆勢的修飾詞保持相同。 一般而言,建議您只 Gesture 使用來自 XAML 的屬性;這可避免模棱兩可、提供最簡化的語法,並提供最直接的串行化表示法。

適用於

另請參閱