Stylus.StylusDown 附加事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當使用者將觸控筆尖端觸碰繪圖板時,會發生這種情況。
see AddStylusDownHandler, and RemoveStylusDownHandler
see AddStylusDownHandler, and RemoveStylusDownHandler
see AddStylusDownHandler, and RemoveStylusDownHandler
範例
以下範例示範如何記錄唱針的座標,即使唱針離開 的 TextBox範圍。 此範例假設存在被呼叫的 TextBox ,且 StylusDown、 StylusUp、 事件StylusMove與事件處理程序相textBox1連。
void textbox1_StylusDown(object sender, StylusDownEventArgs e)
{
Stylus.Capture(textbox1);
}
void textbox1_StylusMove(object sender, StylusEventArgs e)
{
Point pos = e.GetPosition(textbox1);
textbox1.AppendText("X: " + pos.X + " Y: " + pos.Y + "\n");
}
void textbox1_StylusUp(object sender, StylusEventArgs e)
{
Stylus.Capture(textbox1, CaptureMode.None);
}
Private Sub textbox1_StylusDown(ByVal sender As Object, ByVal e As System.Windows.Input.StylusDownEventArgs) _
Handles textbox1.StylusDown
Stylus.Capture(textbox1)
End Sub
Private Sub textbox1_StylusMove(ByVal sender As Object, ByVal e As StylusEventArgs) _
Handles textbox1.StylusMove
Dim pos As Point = e.GetPosition(textbox1)
textbox1.AppendText("X: " & pos.X.ToString() & " Y: " & pos.Y.ToString() & vbLf)
End Sub
Private Sub textbox1_StylusUp(ByVal sender As Object, ByVal e As StylusEventArgs) _
Handles textbox1.StylusUp
Stylus.Capture(textbox1, CaptureMode.None)
End Sub
備註
這是附屬活動。 WPF 將附加事件實作為路由事件。 附加事件基本上是一種 XAML 語言概念,用來參考那些在物件上處理的事件,而這些物件本身並不定義事件。 WPF 進一步擴展附加事件的功能,使其能穿越某條路線。 附加事件在程式碼中沒有直接的處理語法;若要在程式碼中為路由事件附加處理器,請使用指定的 Add*Handler 方法。 詳情請參閱 附件活動概述。
路由事件資訊
| Item | 價值 |
|---|---|
| 識別碼欄位 | StylusDownEvent |
| 路由策略 | 氣泡 |
| 代理人 | StylusDownEventHandler |