Michael Girgis
Michael Girgis

Reputation: 145

How to get Position of Ellipse in WPF C#?

I am creating a bubbles game, that there is a lot of bubbles on the screen moving and i want to pop a bubble when i click on it with mouse.

I can get the position of Mouse easily but i don't know how to get the position of the ellipse in order to check the intersection with the point of the mouse.

Any ideas about how to get the position of ellipses ?!!

I am using Canvas as my container.

Upvotes: 2

Views: 5889

Answers (2)

Rover
Rover

Reputation: 2240

Canvas.GetTop(myEllipse);
Canvas.GetLeft(myEllipse);

How to set ellipse position on Canvas using mouse position

Upvotes: 5

Andrew Jones
Andrew Jones

Reputation: 1001

Why don't you handle PreviewMouseDown (and or PreviewMouseUp) on the Ellipse itself rather than trying to find the clicked ellipse based on position?

Upvotes: 3

Related Questions