Stylus.GotStylusCapture 附加事件

定義

當元素捕捉觸控筆事件時會發生。

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

範例

以下範例示範如何在捕捉並釋放觸控筆事件時改變 的TextBoxTextBox背景色。 此範例假設存在一個稱為 textBox1的文字框,且 GotStylusCaptureLostStylusCapture 事件與事件處理程序相連。

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

備註

這是附屬活動。 WPF 將附加事件實作為路由事件。 附加事件本質上是一種 XAML 語言概念,用來參考那些在物件上處理的事件,而這些物件本身並不定義事件。 WPF 進一步擴展附屬事件的功能,使其能穿越一條路線。 附加事件在程式碼中沒有直接的處理語法;若要在程式碼中為路由事件附加處理器,請使用指定的 Add*Handler 方法。 詳情請參閱 附件活動概述

路由事件資訊

Item 價值
識別碼欄位 GotStylusCaptureEvent
路由策略 氣泡
代理人 StylusEventHandler

適用於

另請參閱