Stylus.StylusLeave Attached Event

Definition

在触笔光标离开元素边界时发生。Occurs when the stylus cursor leaves the bounds of an element.

see AddStylusLeaveHandler, and RemoveStylusLeaveHandler
see AddStylusLeaveHandler, and RemoveStylusLeaveHandler
see AddStylusLeaveHandler, and RemoveStylusLeaveHandler

Examples

下面的示例演示如何在触笔光标进入和离开边界时更改 Button 的颜色。The following example demonstrates how to change the color of a Button when the stylus cursor enters and leaves its bounds. 此示例假设存在一个名为 button1 ButtonStylusEnterStylusLeave 事件连接到事件处理程序。This example assumes that there is a Button called button1 and that the StylusEnter and StylusLeave events are connected to event handlers.

Brush originalColor;

void button1_StylusLeave(object sender, StylusEventArgs e)
{
    button1.Background = originalColor;
}

void button1_StylusEnter(object sender, StylusEventArgs e)
{
    originalColor = button1.Background; 
    button1.Background = Brushes.Gray;
}
Private originalColor As Brush

Private Sub button1_StylusLeave(ByVal sender As Object, ByVal e As StylusEventArgs) _
    Handles button1.StylusLeave

    button1.Background = originalColor

End Sub

Private Sub button1_StylusEnter(ByVal sender As Object, ByVal e As StylusEventArgs) _
    Handles button1.StylusEnter

    originalColor = button1.Background
    button1.Background = Brushes.Gray

End Sub

Remarks

这是一个附加事件。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 StylusLeaveEvent
路由策略Routing strategy 直接Direct
委托Delegate StylusEventHandler

Applies to

See also