UI screen space viewport
Is there a API to get screen space viewport information of any UIElement?
From the following post
viewtopic.php?f=3&t=1542&p=8842&hilit=s ... +box#p8842
I know UIElement.PointToScreen() can calculate screen space coordinate.
So maybe I can compute screen viewport as
Is this viable? or is there already existed some API to do this?
From the following post
viewtopic.php?f=3&t=1542&p=8842&hilit=s ... +box#p8842
I know UIElement.PointToScreen() can calculate screen space coordinate.
So maybe I can compute screen viewport as
Code: Select all
var begin = uielement.PointToScreen(new Point(0, 0));
var end = uielement.PointToScreen(new Point(uielement.width, uielement.height));
Rect viewport = new Rect(begin.x, begin.y, end.x - begin.x, end.y - begin.y);
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: UI screen space viewport
Yes, you can use PointToScreen to determine the coordinates and bounds in screen space of any UIElement:
Code: Select all
Point p0 = element.PointToScreen(new Point(0, 0));
Point p1 = element.PointToScreen(new Point(element.RenderSize.Width, element.RenderSize.Height));
Rect viewport = new Rect(p0, p1);
Re: UI screen space viewport
Alright, understood.
Thank you for quick reply!
Thank you for quick reply!