public static Rect TranslateToParent(this Rect rect, FrameworkElement child, FrameworkElement parent) { foreach (FrameworkElement element in Enumerable.OfType <FrameworkElement>((IEnumerable)VisualTreeExtensions.GetVisualAncestors((DependencyObject)child))) { if (element != parent) { Rect layoutSlot = LayoutInformation.GetLayoutSlot(element); rect = RectExtensions.Translate(rect, layoutSlot.X, layoutSlot.Y); } else { break; } } return(rect); }
public static Rect Translate(this Rect rectangle, Point point) { return(RectExtensions.Translate(rectangle, point.X, point.Y)); }