In WPF something like this would tell me where the border top left corner:
var point = myBorder.PointToScreen(new Point());
How do I get the same in UWP? I can't find any way to get it.
Thank you :)
You can get the screen coordinates of UIElement in following steps:
Get the coordinates of UIElement relative to current application window by following codes:
GeneralTransform transform = myBorder.TransformToVisual(Window.Current.Content);
Point coordinatePointToWindow = transform.TransformPoint(new Point(0, 0));
Get the Rect
information of current application window:
Rect rect = Window.Current.CoreWindow.Bounds;
Calculate the coordinates of your UIElement:
var left = coordinatePointToWindow.X + rect.Left;
var top = coordinatePointToWindow.Y + rect.Top;
You can use TransformToVisual
method. Use the following code
var transformToVisual = myBorder.TransformToVisual(Window.Current.Content);
var borderCoordinats = transformToVisual .TransformPoint(new Point(0, 0));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With