Stylus.StylusUp 附加事件


当用户将触笔从平板电脑处抬起时发生。Occurs when the user raises the stylus from the Tablet PC.

see AddStylusUpHandler, and RemoveStylusUpHandler
see AddStylusUpHandler, and RemoveStylusUpHandler
see AddStylusUpHandler, and RemoveStylusUpHandler


下面的示例演示如何记录触笔的坐标,即使触笔离开的边界也是如此 TextBoxThe following example demonstrates how to record the coordinates of the stylus, even if the stylus leaves the bounds of a TextBox. 此示例假设有一个被 TextBox 调用的 textBox1 ,并且 StylusDownStylusUpStylusMove 事件已连接到事件处理程序。This example assumes that there is a TextBox called textBox1, and that the StylusDown, StylusUp, and StylusMove events are connected to event handlers.

void textbox1_StylusDown(object sender, StylusDownEventArgs e)

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


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


这是一个附加事件。This is an attached event. WPF 将附加事件作为路由事件实现。WPF implements attached events as routed events. 附加事件本质上是一种 XAML 语言概念,用于引用在不具有自身定义事件的对象上处理的事件。An attached event is, fundamentally, a XAML language concept used to reference events that are handled on objects that do not, themselves, define events. WPF 进一步扩展了附加事件的功能,从而允许它遍历路由。WPF 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 StylusUpEvent
路由策略Routing strategy 冒泡Bubbling
委托Delegate StylusEventHandler