KeyEventHandler 代理人
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
public delegate void KeyEventHandler(System::Object ^ sender, KeyEventArgs ^ e);
C#
public delegate void KeyEventHandler(object sender, KeyEventArgs e);
type KeyEventHandler = delegate of obj * KeyEventArgs -> unit
Public Delegate Sub KeyEventHandler(sender As Object, e As KeyEventArgs)
- sender
- Object
附加事件處理常式的物件。
事件資料。
下列範例會檢查與事件相關聯的索引鍵是否為 Return 索引鍵。
C#
private void OnKeyDownHandler(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
{
textBlock1.Text = "You Entered: " + textBox1.Text;
}
}
Private Sub OnKeyDownHandler(ByVal sender As Object, ByVal e As KeyEventArgs)
If (e.Key = Key.Return) Then
textBlock1.Text = "You Entered: " + textBox1.Text
End If
End Sub
此委派會與下列附加事件搭配使用:
此委派也會與基底元素上的下列路由事件搭配使用。 這些路由事件會轉送先前列出的附加事件,讓 WPF 中的一般元素模型更容易存取這些事件。
附加事件和基底元素路由事件會共用其事件數據,而路由事件的反升和通道版本也會共用事件數據。 這可能會影響事件的已處理特性,因為它會移動事件路由。 如需詳細資訊,請參閱 輸入概觀。
Get |
取得表示特定委派所代表之方法的物件。 |
產品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |