如何在调试时检查 xaml 应用中像素中 UI 元素的位置

How to check position of UI elements in pixel in xaml app while debugging

我想检查在调试模式下启动的应用程序中 xaml UI 元素的视觉位置。出于某种原因,我不想在设计器中检查它。有办法吗?这与 html 元素在浏览器中的检查方式非常相似。我们有类似的 UWP 应用程序吗?

I want to check the visually positions of xaml UI elements in the app that is launched in debug mode.

当然,您可以使用 TransformToVisual 方法获取此 UIElement 相对于其父项的位置。

例如

 var ttv = polyline1.TransformToVisual(canvas);
 Point position = ttv.TransformPoint(new Point(0, 0));