Stylus.PreviewStylusButtonDown 附加事件

定义

在用户按下触笔上的其中一个按钮时发生。Occurs when the user presses one of the buttons on the stylus.

see AddPreviewStylusButtonDownHandler, and RemovePreviewStylusButtonDownHandler
see AddPreviewStylusButtonDownHandler, and RemovePreviewStylusButtonDownHandler
see AddPreviewStylusButtonDownHandler, and RemovePreviewStylusButtonDownHandler

示例

下面的示例演示如何确定哪个按钮引发了 PreviewStylusButtonDown 事件。The following example demonstrates how to determine which button raised the PreviewStylusButtonDown event. 此示例假定存在一个名为 TextBoxtextBox1 ,该事件已 PreviewStylusButtonDown 连接到事件处理程序。This example assumes that there is a TextBox called textBox1 and that the PreviewStylusButtonDown event is connected to the event handlers.

void textbox1_PreviewStylusButtonDown(object sender, StylusButtonEventArgs e)
{
    textbox1.AppendText(e.StylusButton.Name + "\n");
}
Private Sub textbox1_PreviewStylusButtonDown(ByVal sender As Object, _
    ByVal e As StylusButtonEventArgs) Handles textbox1.PreviewStylusButtonDown

    textbox1.AppendText(e.StylusButton.Name & vbLf)

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 PreviewStylusButtonDownEvent
路由策略Routing strategy 隧道Tunneling
委托Delegate StylusButtonEventHandler

适用于

另请参阅