【问题标题】:[UWP][C#]Is there a way to get coordinates(left,top Points) of Windows.UI.Xaml.Shapes.Rectangle?[UWP][C#]有没有办法获取 Windows.UI.Xaml.Shapes.Rectangle 的坐标(左、顶点)?
【发布时间】:2020-04-10 15:13:05
【问题描述】:

我正在使用 C# 为 UWP 构建一个 pdf 查看器,并且我正在尝试获取 Windows.UI.Xaml.Shapes.Rectangle 的坐标。 在 .net 框架中,System.Drawing.Rectangle 有两个属性(X,Y)来获取上、左坐标。我想在 UWP 中使用Windows.UI.Xaml.Shapes.Rectangle 做同样的事情。

【问题讨论】:

    标签: c# .net uwp uwp-xaml


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-31
      • 2021-07-21
      • 1970-01-01
      • 1970-01-01
      • 2020-09-05
      • 2013-05-16
      • 1970-01-01
      • 2017-06-28
      相关资源
      最近更新 更多