.NET UIElement.TranslatePoint 的 UWP 等效项 [英] UWP Equivalent of .NET UIElement.TranslatePoint

查看:26
本文介绍了.NET UIElement.TranslatePoint 的 UWP 等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望获取 UIElement 相对于其容器的位置,以在其上叠加图像.

I am looking to get the position of a UIElement relative to it's container to overlay an image on top of it.

System.WINdows 命名空间中的 UIElement 正是我想要的.UWP 中的等价物是什么?

UIElement in the System.WIndows namespace has exactly what I want. What is the equivalent in UWP ?

推荐答案

您可以使用 UIElement.TransformToVisual(UIElement) 方法.

如果您想要左上角,代码如下所示:

If you wanted the top-left point, here's what's the code could look like:

var top_left = child_uiElement.TransformToVisual(container_uiElement).TransformPoint(new Windows.Foundation.Point(0,0));

这篇关于.NET UIElement.TranslatePoint 的 UWP 等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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