Stylus.StylusDown 附加事件

定义

在用户将触笔的笔尖与手写板接触时发生。

see AddStylusDownHandler, and RemoveStylusDownHandler
see AddStylusDownHandler, and RemoveStylusDownHandler
see AddStylusDownHandler, and RemoveStylusDownHandler

示例

以下示例演示如何记录触笔的坐标,即使触笔离开 的 TextBox边界也是如此。 此示例假定有一个名为 TextBoxtextBox1的 ,并且 StylusDownStylusUpStylusMove 事件已连接到事件处理程序。

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 方法。 有关详细信息,请参阅 附加事件概述

路由事件信息

标识符字段 StylusDownEvent
路由策略 鼓 泡
委托 StylusDownEventHandler

适用于

另请参阅