Ottenere la posizione assoluta di un controllo in WinRT

Prima o poi avrete bisogno di ottenere la posizione assoluta di un controllo in WinRT. Potete fare in questo modo:

// Obtain transform information based off root element
GeneralTransform gt = this.TransformToVisual(Window.Current.Content);

// Find the four corners of the element
Point topLeft = gt.TransformPoint(new Point(0, 0));
Point topRight = gt.TransformPoint(new Point(this.RenderSize.Width, 0));
Point bottomLeft = gt.TransformPoint(new Point(0, this.RenderSize.Height));
Point bottomRight = gt.TransformPoint(new Point(this.RenderSize.Width, this.RenderSize.Height));

basato su how-to-get-the-position-of-a-control-in-silverlight

Annunci

How to get the absolute position of a control in WinRT

Sooner or later you will need to find the absolute position of a control in WinRT.
Here is how you can achieve it:

// Obtain transform information based off root element
GeneralTransform gt = this.TransformToVisual(Window.Current.Content);

// Find the four corners of the element
Point topLeft = gt.TransformPoint(new Point(0, 0));
Point topRight = gt.TransformPoint(new Point(this.RenderSize.Width, 0));
Point bottomLeft = gt.TransformPoint(new Point(0, this.RenderSize.Height));
Point bottomRight = gt.TransformPoint(new Point(this.RenderSize.Width, this.RenderSize.Height));

based on how-to-get-the-position-of-a-control-in-silverlight