开发者

How to get the position of a user control?

开发者 https://www.devze.com 2023-01-28 06:07 出处:网络
I have an application. I want to show a ballon(UserControl) after I click a button on window. Th开发者_如何学编程e ballon must appear under the button. How to set the position to ballon using the posi

I have an application. I want to show a ballon(UserControl) after I click a button on window. Th开发者_如何学编程e ballon must appear under the button. How to set the position to ballon using the position on button


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消