getting the co-ordinates of any visual object
-
27. října 2006 6:22
Hi,
is is possible to get the current client co-ordinates of a WPF object in runtime, with out going for a hit-test.
I just have the Name of this control with me, is it possible to get the rectangle area which it is acquiring..
Thanks and Regards
brij
Všechny reakce
-
27. října 2006 9:00Moderátor
if the element is on canvas you could use Canvas.GetLeft, Canvas.GetTop etc -
27. října 2006 11:29
This is not answer to your question but you can review UIElement.InputHitTestand group of the mouse position related properties like UIElement.IsMouseCaptureWithin -
27. října 2006 11:41
The following method can calculate the bounding rectangle area allocated to a specified element:
public static Rect CalculateBounds(FrameworkElement element, Window rootWindow)
{GeneralTransform transform = element.TransformToAncestor(rootWindow);
Point upperLeft = transform.Transform(new Point(0, 0));
Point lowerRight = transform.Transform(new Point(element.ActualWidth, element.ActualHeight));
return new Rect(upperLeft, lowerRight);
}