WinRT中UIElement的绝对坐标 [英] Absolute coordinates of UIElement in WinRT

查看:65
本文介绍了WinRT中UIElement的绝对坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Metro风格应用中找不到找到 UIElement 绝对位置的方法.有人知道解决方案吗?

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)

推荐答案

这应该有效...

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

这篇关于WinRT中UIElement的绝对坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆