Absolute coordinates of UIElement in WinRT

前端 未结 1 1200
天涯浪人
天涯浪人 2021-01-05 00:34

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 ne

1条回答
  •  时光取名叫无心
    2021-01-05 00:53

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

    0 讨论(0)
提交回复
热议问题