Stylus.LostStylusCapture 附加事件
定义
在元素释放触笔事件时发生。Occurs when an element releases stylus events.
see AddLostStylusCaptureHandler, and RemoveLostStylusCaptureHandler
see AddLostStylusCaptureHandler, and RemoveLostStylusCaptureHandler
see AddLostStylusCaptureHandler, and RemoveLostStylusCaptureHandler
示例
下面的示例演示如何 TextBox 在 TextBox 捕获和释放触笔事件时更改的背景色。The following example demonstrates how to change the background color of a TextBox when the TextBox captures and releases stylus events. 此示例假定存在一个名为的文本框 textBox1
,并且 GotStylusCapture 和事件已 LostStylusCapture 连接到该示例中的事件处理程序。This example assumes that there is a textbox called textBox1
, and that the GotStylusCapture and LostStylusCapture events are connected to the event handlers in the example.
void textbox1_LostStylusCapture(object sender, StylusEventArgs e)
{
textbox1.Background = Brushes.White;
}
void textbox1_GotStylusCapture(object sender, StylusEventArgs e)
{
textbox1.Background = Brushes.Red;
}
Private Sub textbox1_LostStylusCapture(ByVal sender As Object, ByVal e As StylusEventArgs) _
Handles textbox1.LostStylusCapture
textbox1.Background = Brushes.White
End Sub
Private Sub textbox1_GotStylusCapture(ByVal sender As Object, ByVal e As StylusEventArgs) _
Handles textbox1.GotStylusCapture
textbox1.Background = Brushes.Red
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 | LostStylusCaptureEvent |
路由策略Routing strategy | 冒泡Bubbling |
委托Delegate | StylusEventHandler |