Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 public static void SetPlacement(UIElement element, RectRelativePlacement value) => element.SetValue(PlacementProperty, value);