Find position of Button/UIElement on screen relative to grid Windows Phone

孤者浪人 提交于 2019-12-30 06:08:41

问题


I can't find a way to get the position in (x,y) co-ordinates of an on-screen control like a button relative to the grid that it is inside. Is there a way to do this that I am overlooking?


回答1:


var transform = button.TransformToVisual(grid);        
Point absolutePosition = transform.Transform(new Point(0, 0));

From How to get the position of an element in a StackPanel?.



来源:https://stackoverflow.com/questions/8206294/find-position-of-button-uielement-on-screen-relative-to-grid-windows-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!