locked
How to find out ManipulationStarting position

    Question

  • I have a canvas element (testCanvas) in which I have many Images that are arranged in a grid (not grid UI element). Now I wont to chang a Pictures Content based on the Input in the canvas, so I dont have to write a an Imagexy_OnTapped function for every Images (up to 100).

    But my problem is, that i can only get the coordinates of the ManipulationStarted event. but since I only Need taps and this function only triggerst after moving the finger or touching with a second one, this won't work. I tried it with  the ManipulationStarting event. This works as far as it Triggers after touching, but I couldn't figure out how to get the coordinates/Position of the Input.

    this is the relevant code. I put the Input data into a TextBox for Debugging purposes.

    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                //other stuff
                testCanvas.ManipulationMode = ManipulationModes.All;
            }
    
            private void testCanvas_ManipulationStarting(object sender, ManipulationStartingRoutedEventArgs e)
            {
                textBoxDebug.Text = "starting...";
            }
    
            private void testCanvas_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
            {
                textBoxDebug.Text = "started...  X: " + e.Position.X.ToString() + ", Y: " + e.Position.Y.ToString();
            }
    maybe there is another way (not with ManipulationStarting) to get touch (or tap... i don't really care) inpout.

    • Edited by jacasch Saturday, August 16, 2014 2:37 PM
    Friday, August 15, 2014 8:32 PM

Answers

  • Solved.

    I started playing around with all manipulationevents (Starting, Started, Completet, Delta). but there I always only get the Position after moving the finger.

    I solved it using the _OnTapped event, of which I get the relative Position to my canvas with GetPosition(). Pretty easy actually. But I found it very badly documented on the web.

    private void testCanvas_Tapped(object sender, TappedRoutedEventArgs e)
            {
                textBoxDebug.Text = "TapPos... X: " + e.GetPosition(testCanvas).X.ToString() + ", Y: " + e.GetPosition(testCanvas).Y.ToString();
            }










    Saturday, August 16, 2014 3:28 PM

All replies

  • Solved.

    I started playing around with all manipulationevents (Starting, Started, Completet, Delta). but there I always only get the Position after moving the finger.

    I solved it using the _OnTapped event, of which I get the relative Position to my canvas with GetPosition(). Pretty easy actually. But I found it very badly documented on the web.

    private void testCanvas_Tapped(object sender, TappedRoutedEventArgs e)
            {
                textBoxDebug.Text = "TapPos... X: " + e.GetPosition(testCanvas).X.ToString() + ", Y: " + e.GetPosition(testCanvas).Y.ToString();
            }










    Saturday, August 16, 2014 3:28 PM
  • Tapped event only occurs after touch off. I'd rather suggest "PointerEntered".

    using Windows.UI.Input;

            private void testCanvas_PointerEntered(object sender, PointerRoutedEventArgs e)
            {
                PointerPoint p;
                p = e.GetCurrentPoint(testCanvas);
                string x = (p.Position.X).toString();

            }


    Sunday, October 05, 2014 3:48 PM