Stylus.PreviewStylusDown 附加事件

定義

使用者以手寫筆尖端碰觸平板電腦時發生。

see AddPreviewStylusDownHandler, and RemovePreviewStylusDownHandler
see AddPreviewStylusDownHandler, and RemovePreviewStylusDownHandler
see AddPreviewStylusDownHandler, and RemovePreviewStylusDownHandler

範例

下列範例示範如何在用戶觸碰手寫筆到平板電腦時,確保不會擷取手寫筆。 此範例假設 PreviewStylusDown 事件已連線到事件處理程式。

void Window1_PreviewStylusDown(object sender, StylusEventArgs e)
{
    IInputElement capturedElement = Stylus.Captured;

    if (capturedElement != null)
    {
        capturedElement.ReleaseStylusCapture();
    }
}
Private Sub Window1_PreviewStylusDown(ByVal sender As Object, ByVal e As StylusDownEventArgs) _
    Handles Me.PreviewStylusDown

    Dim capturedElement As IInputElement = Stylus.Captured

    If Not (capturedElement Is Nothing) Then
        capturedElement.ReleaseStylusCapture()
    End If

End Sub

備註

這是附加事件。 WPF 會將附加事件實作為路由事件。 附加事件基本上是 XAML 語言概念,用來參考未自行定義事件之物件上所處理的事件。 WPF 會進一步擴充附加事件的功能,使其能夠周遊路由。 附加事件在程式代碼中沒有直接處理語法;若要在程式代碼中附加路由事件的處理程式,請使用指定的 Add*Handler 方法。 如需詳細資訊,請參閱 附加事件概觀

路由事件資訊

標識元欄位 PreviewStylusDownEvent
路由策略 隧道
代理人 StylusDownEventHandler

適用於

另請參閱