Stylus.StylusButtonDown 附加事件

定義

使用者按下手寫筆上其中一個按鈕時發生。

see AddStylusButtonDownHandler, and RemoveStylusButtonDownHandler
see AddStylusButtonDownHandler, and RemoveStylusButtonDownHandler
see AddStylusButtonDownHandler, and RemoveStylusButtonDownHandler

範例

下列範例示範如何在使用者按下手寫筆上的滾筒按鈕時顯示快捷方式功能表。 此範例假設有一個名為 TextBoxtextBox1的 ,以及 ContextMenu 稱為 textBoxContextMenu的 ,而且 StylusButtonDown 事件已連接到事件處理程式。

// Show or hide a shortcut menu when the user clicks the barrel button.
void textbox1_StylusButtonDown(object sender, StylusButtonEventArgs e)
{
    if (e.StylusButton.Guid != StylusPointProperties.BarrelButton.Id)
    {
        return;
    }

    if (textbox1.ContextMenu == null)
    {
        textbox1.ContextMenu = textBoxContextMenu;
    }
    else
    {
        textbox1.ContextMenu = null;
    }
}
' Show or hide a shortcut menu when the user clicks the barrel button.
Private Sub textbox1_StylusButtonDown(ByVal sender As Object, ByVal e As StylusButtonEventArgs) _
    Handles textbox1.StylusButtonDown

    If e.StylusButton.Guid <> StylusPointProperties.BarrelButton.Id Then
        Return
    End If

    If textbox1.ContextMenu Is Nothing Then
        textbox1.ContextMenu = textBoxContextMenu
    Else
        textbox1.ContextMenu = Nothing
    End If

End Sub

備註

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

路由事件資訊

標識元欄位 StylusButtonDownEvent
路由策略 鼓 泡
代理人 StylusButtonEventHandler

適用於

另請參閱