Stylus.GotStylusCapture Stylus.GotStylusCapture Stylus.GotStylusCapture Attached Event

定义

在元素捕获到触笔事件时发生。Occurs when an element captures the stylus events.

see AddGotStylusCaptureHandler, and RemoveGotStylusCaptureHandler
see AddGotStylusCaptureHandler, and RemoveGotStylusCaptureHandler
see AddGotStylusCaptureHandler, and RemoveGotStylusCaptureHandler

示例

下面的示例演示如何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 event handlers.

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 'textbox1_LostStylusCapture


Private Sub textbox1_GotStylusCapture(ByVal sender As Object, ByVal e As StylusEventArgs) _
    Handles textbox1.GotStylusCapture

    textbox1.Background = Brushes.Red

End Sub 'textbox1_GotStylusCapture

注解

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

适用于

另请参阅