发现相对于电网的Windows Phone屏幕按钮/ UIElement的位置 [英] Find position of Button/UIElement on screen relative to grid Windows Phone
本文介绍了发现相对于电网的Windows Phone屏幕按钮/ UIElement的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不能找到一种方式来获得的(X,Y)屏幕上的控制相对于它的内部电网的一个按钮一样的坐标位置。有没有办法做到这一点,我可以俯瞰?
解决方案
VAR变换=按钮.TransformToVisual(网格);
点absolutePosition位置= transform.Transform(新点(0,0));
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));
From How to get the position of an element in a StackPanel?.
这篇关于发现相对于电网的Windows Phone屏幕按钮/ UIElement的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文