-2

I have an array which stores many images within in. I am trying to figure out how to get the position of the image (x,y) within the window. I aim to put it in a timer so I can get the updated location as the program runs.

The images are added with the following code:

arrayName[p] = new Image();
arrayName[p].Source = new BitmapImage(new Uri(@"imgPlaneSprite.png", UriKind.Relative));
arrayName[p].Width = 50;
arrayName[p].Height = 50;
arrayName[p].Stretch = Stretch.Fill;

LayoutRoot.Children.Add(arrayName[p]);
ThomasArdal
  • 4,999
  • 4
  • 33
  • 73
  • [There](https://stackoverflow.com/questions/4095252) [is](https://stackoverflow.com/questions/386731) [already](https://stackoverflow.com/questions/4492734) [many](https://stackoverflow.com/questions/54076063) SO [questions](https://stackoverflow.com/questions/1923697) on this subject. – Orace Jun 15 '22 at 08:44

1 Answers1

1

try this:

arrayName[p].PointToScreen(new Point(0, 0));
Shunya
  • 2,344
  • 4
  • 16
  • 28
Hanebu
  • 133
  • 9