Stylus.PreviewStylusMove Stylus.PreviewStylusMove Stylus.PreviewStylusMove Attached Event

定义

触笔接触平板电脑并移动时发生。Occurs when the stylus moves while it is touching the tablet.

see AddPreviewStylusMoveHandler, and RemovePreviewStylusMoveHandler
see AddPreviewStylusMoveHandler, and RemovePreviewStylusMoveHandler
see AddPreviewStylusMoveHandler, and RemovePreviewStylusMoveHandler

示例

该示例演示如何在触笔移动时确定其位置。The example demonstrates how to determine the position of the stylus when it moves. 此示例假定存在一个TextBoxtextBox1为的, PreviewStylusMove该事件已连接到事件处理程序。This example assumes that there is a TextBox called textBox1 and that the PreviewStylusMove event is connected to the event handlers.

void textbox1_PreviewStylusMove(object sender, StylusEventArgs e)
{
    Point pos = e.GetPosition(textbox1);
    textbox1.AppendText("X: " + pos.X + " Y: " + pos.Y + "\n");
}
Private Sub textbox1_PreviewStylusMove(ByVal sender As Object, _
    ByVal e As StylusEventArgs) Handles textbox1.PreviewStylusMove

    Dim pos As Point = e.GetPosition(textbox1)
    textbox1.AppendText("X: " & pos.X & " Y: " & pos.Y & vbLf)

End Sub

注解

这是一个附加事件。This is an attached event. WPFWPF将附加事件作为路由事件实现。implements attached events as routed events. 附加事件本质上是一种XAMLXAML语言概念, 它用于引用处理的事件, 这些事件本身不是定义事件。An attached event is, fundamentally, a XAMLXAML language concept used to reference events that are handled on objects that do not, themselves, define events. WPFWPF进一步扩展了附加事件的功能, 从而允许它遍历路由。further expands an attached event's capabilities, allowing it to traverse a route. 附加事件在代码中没有直接处理语法;若要在代码中附加路由事件的处理程序, 请使用指定的 Add * 处理程序方法。Attached events do not have a direct handling syntax in code; to attach handlers for a routed event in code, use a designated Add*Handler method. 有关详细信息, 请参阅附加事件概述For details, see Attached Events Overview.

路由事件信息Routed Event Information

标识符字段Identifier field PreviewStylusMoveEvent
路由策略Routing strategy 建立Tunneling
委托Delegate StylusEventHandler

适用于

另请参阅