Stylus.PreviewStylusInRange Stylus.PreviewStylusInRange Stylus.PreviewStylusInRange Attached Event


手寫筆進入平板電腦的範圍內時發生。Occurs when the stylus comes within range of the tablet.

see AddPreviewStylusInRangeHandler, and RemovePreviewStylusInRangeHandler
see AddPreviewStylusInRangeHandler, and RemovePreviewStylusInRangeHandler
see AddPreviewStylusInRangeHandler, and RemovePreviewStylusInRangeHandler


下列範例示範如何判斷手寫筆是否反轉。The following example demonstrates how to determine whether the stylus is inverted. 這個範例假設有一個TextBox呼叫textBox1 , 而且該PreviewStylusInRange事件已連接到事件處理常式。This example assumes that there is a TextBox called textBox1 and that the PreviewStylusInRange event is connected to the event handlers.

void textbox1_PreviewStylusInRange(object sender, StylusEventArgs e)
    if (e.StylusDevice.Inverted)
        textbox1.AppendText("Pen is inverted\n");
        textbox1.AppendText("Pen is not inverted\n");
Private Sub textbox1_PreviewStylusInRange(ByVal sender As Object, _
    ByVal e As StylusEventArgs) Handles textbox1.PreviewStylusInRange

    If e.StylusDevice.Inverted Then
        textbox1.AppendText("Pen is inverted" & vbLf)
        textbox1.AppendText("Pen is not inverted" & vbLf)
    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 PreviewStylusInRangeEvent
路由策略Routing strategy 建立Tunneling
Delegate - 委派Delegate StylusEventHandler