How to get the position of a user control?

I have an application. I want to show the balloon (UserControl) after clicking the button on the window. The balloon should appear under the button. How to set the position on the container using the position on the button

+3
source share
1 answer
Button

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

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

Take prey in TransformToAncestor , it works for any visual.

+7
source

Source: https://habr.com/ru/post/1778605/


All Articles