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為的 textbox, 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


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語言概念, 用來參考在不會定義事件的物件上處理的事件。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 - 委派Delegate StylusEventHandler

適用於

另請參閱