ContentElement.PreviewKeyDown ContentElement.PreviewKeyDown ContentElement.PreviewKeyDown ContentElement.PreviewKeyDown Event

定義

鍵盤以此元素為焦點且按下按鍵時發生。Occurs when a key is pressed while the keyboard is focused on this element.

public:
 virtual event System::Windows::Input::KeyEventHandler ^ PreviewKeyDown;
public event System.Windows.Input.KeyEventHandler PreviewKeyDown;
member this.PreviewKeyDown : System.Windows.Input.KeyEventHandler 
Public Custom Event PreviewKeyDown As KeyEventHandler 

實作

備註

金鑰處理會與其他平臺功能 (例如命令和文字撰寫) 互動。Key handling interacts with other platform features such as commanding and text composition. KeyDown事件是較低層級的文字輸入事件, 其在某些控制項上可能無法如預期般運作。The KeyDown event is a lower-level text input event that might not behave as expected on certain controls. 這是因為有些控制項具有控制項撰寫或類別處理, 可提供較高層級的文字輸入處理和相關事件。This is because some controls have control compositing or class handling that provides a higher-level version of text input handling and related events.

這個事件PreviewKeyDown會為這個類別建立Keyboard.PreviewKeyDown附加事件的別名, 因此當繼承為基底專案時ContentElement , 就是類別成員清單的一部分。This event creates an alias for the Keyboard.PreviewKeyDown attached event for this class, so that PreviewKeyDown is part of the class members list when ContentElement is inherited as a base element. 附加至PreviewKeyDown事件的事件處理常式會附加至基礎Keyboard.PreviewKeyDown附加事件, 並接收相同的事件資料實例。Event handlers that are attached to the PreviewKeyDown event are attached to the underlying Keyboard.PreviewKeyDown attached event and receive the same event data instance.

路由事件資訊Routed Event Information

識別碼欄位Identifier field PreviewKeyDownEvent
路由策略Routing strategy 建立Tunneling
Delegate - 委派Delegate KeyEventHandler
  • 對應的反升事件KeyDown為。The corresponding bubbling event is KeyDown.

  • OnPreviewKeyDown寫以在衍生類別中為這個事件執行類別處理。Override OnPreviewKeyDown to implement class handling for this event in derived classes.

適用於

另請參閱