![](/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.