PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 30, 2022

[FIXED] How to find the position of an Image in WPF C#?

 July 30, 2022     c#, image, location, wpf     No comments   

Issue

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]);

Solution

try this:

arrayName[p].PointToScreen(new Point(0, 0));


Answered By - Hanebu
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing