Stylus.StylusEnter Stylus.StylusEnter Stylus.StylusEnter Attached Event

定義

手寫筆游標進入項目的邊界時發生。Occurs when the stylus cursor enters the bounds of an element.

see AddStylusEnterHandler, and RemoveStylusEnterHandler
see AddStylusEnterHandler, and RemoveStylusEnterHandler
see AddStylusEnterHandler, and RemoveStylusEnterHandler

範例

下列範例示範如何變更的色彩Button當手寫筆游標進入和離開其邊界。The following example demonstrates how to change the color of a Button when the stylus cursor enters and leaves its bounds. 這個範例假設有Buttonbutton1而且StylusEnterStylusLeave事件都已連接的事件處理常式。This example assumes that there is a Button called button1 and that the StylusEnter and StylusLeave events are connected to the 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 'button1_StylusLeave

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

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

End Sub 'button1_StylusEnter

備註

這是附加的事件。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. 附加的事件並沒有直接處理語法在程式碼若要附加的程式碼中的路由事件處理常式,使用指定的新增 * 處理常式方法。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 StylusEnterEvent
路由策略Routing strategy 直接Direct
Delegate - 委派Delegate StylusEventHandler

適用於

另請參閱