我正在使用 C# 为 UWP 构建一个 pdf 查看器,我正在尝试获取Windows.UI.Xaml.Shapes.Rectangle
的坐标。 在.net框架中,System.Drawing.Rectangle
有两个属性(X,Y
(来获取顶部,左侧坐标。我想使用Windows.UI.Xaml.Shapes.Rectangle
在 UWP 中做同样的事情。
[UWP][C#]有没有办法获取Windows.UI.Xaml.Shapes.Rectangle的坐标(左,顶点(?
您可以使用TransformToVisual
来获取Window.Current.Content
的相对坐标。有关详细信息,请参阅以下代码。
var trc = TestRect.TransformToVisual(Window.Current.Content);
Point screenCoords = trc.TransformPoint(new Point(0, 0));