///<summary> /// Returns the visual child of the given element that is under position ///</summary> public static Visual GetHitChild(this Visual element, Point position) { for (int Index = 0; Index < VisualTreeHelper.GetChildrenCount(element); Index++) { Visual Child = VisualTreeHelper.GetChild(element, Index) as Visual; if (Child != null && VisualTreeHelperEx.GetBounds(element, Child).Contains(position)) { return(Child); } } return(null); }
///<summary> /// Returns the bounds of the element, at location within reference ///</summary> public static Rect GetBounds(Visual reference, Visual uiElement) { Rect Bounds = VisualTreeHelperEx.GetBounds(uiElement); return(uiElement.TransformToVisual(reference).TransformBounds(Bounds)); }