Stylus.StylusInRange Stylus.StylusInRange Stylus.StylusInRange Attached Event

定义

在触笔进入绘图板范围时发生。Occurs when the stylus comes within range of the tablet.

see AddStylusInRangeHandler, and RemoveStylusInRangeHandler
see AddStylusInRangeHandler, and RemoveStylusInRangeHandler
see AddStylusInRangeHandler, and RemoveStylusInRangeHandler

示例

下面的示例演示如何在触笔EditingMode反转时将InkCanvasEraseByStroke属性设置为。The following example demonstrates how to set the EditingMode property of an InkCanvas to EraseByStroke when the stylus is inverted. 此示例假定存在一个InkCanvasinkCanvas1为的, StylusInRange该事件已连接到事件处理程序。This example assumes that there is an InkCanvas called inkCanvas1 and that the StylusInRange event is connected to the event handlers. 若要查看光标更改, 请将UseCustomCursor属性设置trueinkCanvas1"开"。To see the cursor change, set the UseCustomCursor property to true on inkCanvas1.

void inkCanvas1_StylusInRange(object sender, StylusEventArgs e)
{
    if (e.StylusDevice.Inverted == true)
    {
        inkCanvas1.EditingMode = InkCanvasEditingMode.EraseByStroke;
        inkCanvas1.Cursor = System.Windows.Input.Cursors.Hand;
    }
    else
    {
        inkCanvas1.EditingMode = InkCanvasEditingMode.Ink;
        inkCanvas1.Cursor = System.Windows.Input.Cursors.Pen;
    }
}
Private Sub inkCanvas1_StylusInRange(ByVal sender As Object, ByVal e As StylusEventArgs) _
    Handles inkCanvas1.StylusInRange

    If e.StylusDevice.Inverted = True Then
        inkCanvas1.EditingMode = InkCanvasEditingMode.EraseByStroke
        inkCanvas1.Cursor = System.Windows.Input.Cursors.Hand
    Else
        inkCanvas1.EditingMode = InkCanvasEditingMode.Ink
        inkCanvas1.Cursor = System.Windows.Input.Cursors.Pen
    End If

End Sub

注解

这是一个附加事件。This is an attached event. WPFWPF将附加事件作为路由事件实现。implements attached events as routed events. 附加事件本质上是一种XAMLXAML语言概念, 它用于引用处理的事件, 这些事件本身不是定义事件。An attached event is, fundamentally, a XAMLXAML language concept used to reference events that are handled on objects that do not, themselves, define events. 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 StylusInRangeEvent
路由策略Routing strategy 冒泡Bubbling
委托Delegate StylusEventHandler

适用于

另请参阅