简体   繁体   中英

[UWP][C#]Is there a way to get coordinates(left,top Points) of Windows.UI.Xaml.Shapes.Rectangle?

I'm building a pdf viewer for UWP using C# and I'm trying to get the coordinates of the Windows.UI.Xaml.Shapes.Rectangle . In .net framework, System.Drawing.Rectangle has two properties( X,Y ) to get top, left coordinate. I want to do the same in UWP using Windows.UI.Xaml.Shapes.Rectangle .

[UWP][C#]Is there a way to get coordinates(left,top Points) of Windows.UI.Xaml.Shapes.Rectangle?

You could use TransformToVisual to get relative coordinate for Window.Current.Content . For detail please refer the following code.

var trc = TestRect.TransformToVisual(Window.Current.Content);
Point screenCoords = trc.TransformPoint(new Point(0, 0));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM