9

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)

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
snuk182
  • 1,022
  • 1
  • 12
  • 28

1 Answers1

22

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));
}
Jeff Brand
  • 5,623
  • 1
  • 23
  • 22