user3511077
user3511077

Reputation: 11

how to get coordinate of control in windows phone 7

i want to know how to get coordinate (x,y) of 2 Textboxes and compare each others, i saw some code use GeoCoordinate then i try it but i don't know why my visual studio doesn't support that library, help me and give me some code example for get (x,y) of controls, i'm using visual studio 2010 and OS 7.1

Upvotes: 0

Views: 72

Answers (1)

Error418
Error418

Reputation: 309

I think GeoCoordinate is for GPS position, you can't use it to localise control in a grid.

However, you can use this code to localise control relatively to a grid or a stackPanel thank to the code below :

    var transform1 = textBox1.TransformToVisual(grid);//Grid is your content panel 
    Point absolutePosition1 = transform1.Transform(new Point(0, 0));

    var transform2 = textBox2.TransformToVisual(grid);//Grid is your content panel 
    Point absolutePosition2 = transform2.Transform(new Point(0, 0));

After that, you can compare them.

Upvotes: 1

Related Questions