private static Point CalculatePositionRelativeToRect(Rect rect, RectRelativePlacement childPlacement, Size childSize) { var childCenterPointRelativeToRect = childPlacement.GetPositionRelativeTo(rect); var childCenterToTopLeftVector = new Vector(-childSize.Width / 2, -childSize.Height / 2); return(childCenterPointRelativeToRect + childCenterToTopLeftVector); }
private static Point CalculateChildPosition(Rect decoratedRect, RectRelativePlacement childPlacement, Size childSize) { var childCenterPointRelativeToParent = childPlacement.GetPositionRelativeTo(decoratedRect); var childCenterToTopLeftVector = new Vector(-childSize.Width / 2, -childSize.Height / 2); var childTopLeftPointRelativeToParent = childCenterPointRelativeToParent + childCenterToTopLeftVector; return(childTopLeftPointRelativeToParent); }
public static void SetPlacement(UIElement element, RectRelativePlacement value) => element.SetValue(PlacementProperty, value);