Absolute coordinates of UIElement in WinRT

蹲街弑〆低调 提交于 2019-11-30 03:15:29

问题


Cannot find a way to locate absolute position of an UIElement in Metro style app. Anybody know the solution?

(the context: I want a Popup to be shown next to the button called it)


回答1:


This should work...

private void Button_Click(object sender, RoutedEventArgs e)
{
   var button = sender as Button;
   var ttv = button.TransformToVisual(Window.Current.Content);
   Point screenCoords = ttv.TransformPoint(new Point(0, 0));
}


来源:https://stackoverflow.com/questions/12161584/absolute-coordinates-of-uielement-in-winrt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!