![](/img/trans.png)
[英]How to always position a control to a fixed location on screen in silverlight on wp7?
[英]How do you find the screen position of a control in silverlight on WP7?
如何在WP7上找到silverlight中控件的屏幕位置?
任何建议都非常感谢。
如果你知道它是如何定位的(例如在Canvas
),可能有更合适的方法来做事,但一般来说,你可以使用UIElement.TransformToVisual
在控件和全局坐标系之间进行转换:
var transform = myControl.TransformToVisual(Application.Current.RootVisual)
var offset = transform.Transform(new Point(0,0))
在尝试执行此操作之前,请确保控件已经过布局,如果过早地执行此操作,则错误消息通常无益。
(MSDN建议WP7中存在该方法,我没有安装SDK进行测试)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.