juste3alfaza
juste3alfaza

Reputation: 35

Detect x & y touch event in WP7 screen

I am really need help with return the coordinates x and y in the WP7 screen. this code help me to move an rectangle in the screen with showing the start(x&y), delta(x,y) and end(x,y) :

TransformGroup transformG;
    TranslateTransform translation;

    // Constructor
    public MainPage()
    {
        InitializeComponent();
        this.ManipulationDelta += new EventHandler<ManipulationDeltaEventArgs>(MainPage_ManipulationDelta);
        transformG = new TransformGroup();
        translation = new TranslateTransform();
        transformG.Children.Add(translation);
        rectangle.RenderTransform = transformG;
    }

    void MainPage_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
    {
        startX.Text =e.ManipulationOrigin.X.ToString();
        startY.Text = e.ManipulationOrigin.Y.ToString();
        DeltaX.Text = e.DeltaManipulation.Translation.X.ToString();
        DeltaY.Text = e.DeltaManipulation.Translation.Y.ToString();
        translation.X += e.DeltaManipulation.Translation.X;
        translation.Y += e.DeltaManipulation.Translation.Y;
        EndX.Text =Convert.ToString(translation.X);
        EndY.Text = Convert.ToString(translation.Y);
    }

I just want to do something like that but without move anything, just tap in the screen and know the start and the end with delta (difference). I use silverlight

Upvotes: 2

Views: 456

Answers (1)

Igor Meszaros
Igor Meszaros

Reputation: 2127

You Should remove rectangle.RenderTransform = transformG; than the rectangle should stay on the same place.

Upvotes: 1

Related Questions