有没有办法在 Windows Phone 上获取控件的绝对屏幕坐标?此外,如果该方法适用于 UserControl 组件,也会有所帮助。WPF 似乎有 Control.PointToScreen,它不在 WP API 中
我的想法是我正在尝试使用 Callout 控件指向屏幕上的 UserControl 作为帮助气泡,并且锚点也不采用绝对坐标 - 所以这是一个巨大的连接问题,我将建立作为对这篇文章的回答。
有没有办法在 Windows Phone 上获取控件的绝对屏幕坐标?此外,如果该方法适用于 UserControl 组件,也会有所帮助。WPF 似乎有 Control.PointToScreen,它不在 WP API 中
我的想法是我正在尝试使用 Callout 控件指向屏幕上的 UserControl 作为帮助气泡,并且锚点也不采用绝对坐标 - 所以这是一个巨大的连接问题,我将建立作为对这篇文章的回答。
Use UIElement.TransformToVisual()
something like this should do the trick:
var control = this; // assign the control you want to get the position of.
var transform = control.TransformToVisual(Application.Current.RootVisual);
var controlPosition = transform.Transform(new Point(0, 0));
也许你可以Control.MousePosition
试试
这是你想要的吗(尽管它适用于 WP7):如何在 WP7 上的 silverlight 中找到控件的屏幕位置?