简体   繁体   中英

Absolute coordinates of UIElement in WinRT

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)

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));
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM