Getting current point from Manipulation events

njsokalski

Well-known member
Joined
Mar 16, 2011
Messages
102
Programming Experience
5-10
I have an application in which I want to get the point currently being touched during a Manipulation event. I currently have the following test code:

<Grid>
<Image Name="imgManipulation" HorizontalAlignment="Left" Stretch="None" VerticalAlignment="Top" Height="750" Width="480"/>
</Grid>


Private Sub imgManipulation_ManipulationDelta(sender As Object, e As System.Windows.Input.ManipulationDeltaEventArgs) Handles imgManipulation.ManipulationDelta
System.Diagnostics.Debug.WriteLine("{0},{1}", e.CumulativeManipulation.Translation.X, e.CumulativeManipulation.Translation.Y)
End Sub

Private Sub imgManipulation_ManipulationStarted(sender As Object, e As System.Windows.Input.ManipulationStartedEventArgs) Handles imgManipulation.ManipulationStarted
System.Diagnostics.Debug.WriteLine("Origin: {0},{1}", e.ManipulationOrigin.X, e.ManipulationOrigin.Y)
End Sub


And when I run the debugger/emulator, I receive output such as the following:

Origin: 31,36
-2,0
-4,0
-7,0
-9,0

In this particular example, I slid to the left edge of the emulator screen. Several things I have noticed that I don't understand are:

1. Each X,Y has a difference of either 2 or 3 from the previous one. I would have expected them to have a difference of 1. Why is the event not being fired for every point? Is this only on the emulator, or do I need to do something different?
2. Because I slid to the edge of the emulator screen, I would have expected the last X to be the opposite of the origin X, but it is not (31-9 does not equal 0). Instead, it seems to always come out to a value of 22 (31-9=22). Where do these extra 22 come from, and what can I do about them?

I am somewhat new to detecting and working with exact coordinates in Windows Phone 7, so can somebody tell me how to get and/or detect the following:

1. The currently touched point relative to the upper-left of the element
2. The currently touched point relative to the upper-left of the screen

Any help is appreciated. Thanks.
 
Back
Top