查找 Button/UIElement 在屏幕上相对于网格 Windows Phone 的位置 [英] Find position of Button/UIElement on screen relative to grid Windows Phone

查看:14
本文介绍了查找 Button/UIElement 在屏幕上相对于网格 Windows Phone 的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到一种方法来获取屏幕控件(例如按钮)相对于其内部网格的 (x,y) 坐标位置.有没有办法做到这一点,我忽略了?

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?

推荐答案

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

来自 如何获取StackPanel 中的元素?.

这篇关于查找 Button/UIElement 在屏幕上相对于网格 Windows Phone 的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆