Stylus.StylusMove 附加事件
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
手寫筆碰觸平板電腦且移動時發生。
C#
see AddStylusMoveHandler, and RemoveStylusMoveHandler
see AddStylusMoveHandler, and RemoveStylusMoveHandler
see AddStylusMoveHandler, and RemoveStylusMoveHandler
下列範例示範如何記錄手寫筆的座標,即使手寫筆離開 的界限 TextBox也一樣。 這個範例假設有一個 TextBox 稱為 textBox1
的 ,而且 StylusDown、 StylusUp和 StylusMove 事件會連線到事件處理程式。
C#
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 方法。 如需詳細資訊,請參閱 附加事件概觀。
標識元欄位 | StylusMoveEvent |
路由策略 | 鼓 泡 |
代理人 | StylusEventHandler |
產品 | 版本 |
---|---|
.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 |