locked
Coordinats within a controll RRS feed

  • Question

  • I would like to know how i can get the coordinates within a control as i move my finger over it so that i can move another object on the screen in the same pattern.

    Thanks in advance

    Wednesday, December 18, 2013 7:24 AM

Answers

  • You get that position by referring to the control inside GetCurrentPoint. If this is your XAML:

    <Border x:Name="TheBorder"
            Grid.Column="1"
            PointerMoved="Border_PointerMoved" />

    Then you find the position inside this Border like this:

    private void Border_PointerMoved(object sender, PointerRoutedEventArgs e)
    {
        var position = e.GetCurrentPoint(this.TheBorder).Position;
        // ...
    }


    • Edited by Diederik KrolsMVP Wednesday, December 18, 2013 7:49 AM
    • Marked as answer by Anne Jing Thursday, December 26, 2013 2:18 AM
    Wednesday, December 18, 2013 7:49 AM
  • Hi,

    Just like Diederik says, you can listen for pointer events and get access to extended pointer data exposed by a PointerPoint object through the GetCurrentPoint and GetIntermediatePoints methods of PointerRoutedEventArgs.

    Refer to the link below to get more information:

    http://msdn.microsoft.com/en-us/library/windows/apps/jj150606.aspx

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Anne Jing Thursday, December 26, 2013 2:18 AM
    Thursday, December 19, 2013 6:02 AM

All replies

  • You get that position by referring to the control inside GetCurrentPoint. If this is your XAML:

    <Border x:Name="TheBorder"
            Grid.Column="1"
            PointerMoved="Border_PointerMoved" />

    Then you find the position inside this Border like this:

    private void Border_PointerMoved(object sender, PointerRoutedEventArgs e)
    {
        var position = e.GetCurrentPoint(this.TheBorder).Position;
        // ...
    }


    • Edited by Diederik KrolsMVP Wednesday, December 18, 2013 7:49 AM
    • Marked as answer by Anne Jing Thursday, December 26, 2013 2:18 AM
    Wednesday, December 18, 2013 7:49 AM
  • Hi,

    Just like Diederik says, you can listen for pointer events and get access to extended pointer data exposed by a PointerPoint object through the GetCurrentPoint and GetIntermediatePoints methods of PointerRoutedEventArgs.

    Refer to the link below to get more information:

    http://msdn.microsoft.com/en-us/library/windows/apps/jj150606.aspx

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Anne Jing Thursday, December 26, 2013 2:18 AM
    Thursday, December 19, 2013 6:02 AM
  • Thank you for your help, it was just what i needed. But i had to give the Border a Background before it worked.

    //Zadrith

    Thursday, January 2, 2014 8:22 PM
  • Hi,

    Do you mean you want to change the border‘s Backgroud when you point over/move on it:

    You can do this in PointerMoved/PointerOver event:

     private void Border_PointerMoved(object sender, PointerRoutedEventArgs e)
            {
               
                TheBorder.Background = new SolidColorBrush(Colors.Blue);
    
            }

    And you can get back to the Boder's original background color in PointerExited event:

    private void TheBorder_PointerExited(object sender, PointerRoutedEventArgs e) {

    //assume the border's original background color is beige color TheBorder.Background = new SolidColorBrush(Colors.Beige); }


    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, January 3, 2014 7:52 AM