Windows Phone 8.1 Development: Touch and Pointer Events 2

Source: Internet
Author: User

Source: http://www.bcmeng.com/windows-phone-touch1/

Please enter the content here (want to die, wrote for one hours, directly did not save accidentally deleted. Let's just say it. The pointer event has the following events:

    • Pointercanceled
    • Pointerentered
    • PointerExited
    • PointerMoved
    • Pointerpressed
    • Pointerreleased
    • Pointercapturelost

The order of initiation is as follows:

When clicked: The Tap event raises the sequence of touch and pointer events as follows:

12:4:8-pointerentered event occurred

12:4:8-pointerpressed event occurred
12:4:8-manipulationstarting event occurred
12:4:8-pointermoved event occurred
12:4:8-pointermoved event occurred
12:4:8-pointerreleased event occurred
12:4:8-tapped event occurred
12:4:8-pointerexited event occurred

When long on time: The Righttap event raises the following touch and pointer events:
12:6:15-pointerentered event occurred
12:6:15-pointerpressed event occurred
12:6:15-manipulationstarting event occurred
12:6:15-pointermoved event occurred
12:6:15-pointermoved event occurred
12:6:16-pointerreleased event occurred
12:6:16-righttapped event occurred
12:6:16-pointerexited event occurred

On the meaning of each pointer event, we can also know according to the name, small dream just write very detailed, but no, everyone directly refer to the MSDN documentation. However, be aware that:

Each time a touch operation produces a pointerpressed event, the event is immediately after the pointerentered event, and all event data has the same information (same pointer ID, same location, and so on) for both events

The pointerpressed and pointerreleased events are not always paired up. Your application should listen to and handle actions that might draw a point (such as PointerExited,pointercanceled , and pointercapturelostanyway).

The following shows an instance of a stroke drawing implemented through pointer events and line controls:

First define a canvas:

<canvas name="Canvas" Background="Transparent" pointerpressed="canvas_pointerpressed" PointerMoved="canvas_pointermoved"></Canvas>

Background logic:

PrivatePoint Currentpoint;//latest, Current pointPrivatePoint Oldpoint;//Previous PointPrivate voidCanvas_pointerpressed (Objectsender, Pointerroutedeventargs e) {Currentpoint=e.getcurrentpoint (Canvas). Position;oldpoint=Currentpoint;}Private voidCanvas_pointermoved (Objectsender, Pointerroutedeventargs e) {Currentpoint=e.getcurrentpoint (Canvas). Position; Line Line=NewLine () {X1 = currentpoint.x, Y1 = currentpoint.y, X2 = oldpoint.x, Y2 =Oldpoint.y};line. Stroke=NewSolidColorBrush (colors.red); StrokeThickness=5; line. Strokelinejoin=Penlinejoin.round;line. StrokeStartLineCap=Penlinecap.round;line. Strokeendlinecap=Penlinecap.round; This. Canvas. Children.add (line); Oldpoint=Currentpoint;}

If you are not sure about the properties of line, please refer to Msdn:http://msdn.microsoft.com/library/windows/apps/system.windows.shapes.shape (v=vs.105). aspx

The results are as follows:

Windows Phone touch and pointer source code download, click I download Oh!

Windows Phone 8.1 development: Touch and pointer Events 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.