开发者

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. 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜