Prince OfThief
Prince OfThief

Reputation: 6423

How to get the position of a user control?

I have an application. I want to show a ballon(UserControl) after I click a button on window. The ballon must appear under the button. How to set the position to ballon using the position on button

Upvotes: 3

Views: 13727

Answers (1)

Nicolas Repiquet
Nicolas Repiquet

Reputation: 9265

button is your button, root is your window and coordinates is the coordinates of button relative to root.

Point coordinates = button.TransformToAncestor(root).Transform(new Point(0, 0));

Take a loot at TransformToAncestor, it works for any visual.

Upvotes: 7

Related Questions