Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 294
snuk182 Avatar asked Aug 28 '12 14:08

snuk182


1 Answers

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));
}
like image 50
Jeff Brand Avatar answered Oct 25 '22 17:10

Jeff Brand