Stylus.StylusButtonDown 添付イベント
定義
ユーザーがスタイラス上のボタンのいずれかを押したときに発生します。Occurs when the user presses one of the buttons on the stylus.
see AddStylusButtonDownHandler, and RemoveStylusButtonDownHandler
see AddStylusButtonDownHandler, and RemoveStylusButtonDownHandler
see AddStylusButtonDownHandler, and RemoveStylusButtonDownHandler
例
次の例は、ユーザーがスタイラスで胴体ボタンを押したときにショートカットメニューを表示する方法を示しています。The following example demonstrates how to show a shortcut menu when the user presses the barrel button on a stylus. この例では、が呼び出され、が呼び出されて TextBox textBox1
おり、 ContextMenu textBoxContextMenu
StylusButtonDown イベントがイベントハンドラーに接続されていることを前提としています。This example assumes that there is a TextBox called textBox1
, and a ContextMenu called textBoxContextMenu
, and that the StylusButtonDown event is connected to the event handler.
// 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
注釈
これは添付イベントです。This is an attached event. WPF は、添付イベントをルーティングイベントとして実装します。WPF implements attached events as routed events. 添付イベントとは、本質的には、イベントを定義するのではなく、オブジェクトで処理されるイベントを参照するために使用される XAML 言語の概念です。An attached event is, fundamentally, a XAML language concept used to reference events that are handled on objects that do not, themselves, define events. WPF は、添付イベントの機能をさらに拡張し、ルートを走査できるようにします。WPF further expands an attached event's capabilities, allowing it to traverse a route. アタッチされたイベントには、コードで直接処理構文がありません。コードでルーティングイベントのハンドラーをアタッチするには、指定された Add * Handler メソッドを使用します。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 | StylusButtonDownEvent |
ルーティング方法Routing strategy | バブリングBubbling |
代理人Delegate | StylusButtonEventHandler |