示例#1
0
 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);
 }
示例#2
0
 public static Rect Translate(this Rect rectangle, Point point)
 {
     return(RectExtensions.Translate(rectangle, point.X, point.Y));
 }