protected override Foundation.Size MeasureOverride(Foundation.Size size)
        {
            var child = Content as UIElement;

            if (child != null)
            {
                var slotSize = size;
                if (VerticalScrollBarVisibility != ScrollBarVisibility.Disabled)
                {
                    slotSize.Height = double.PositiveInfinity;
                }
                if (HorizontalScrollBarVisibility != ScrollBarVisibility.Disabled)
                {
                    slotSize.Width = double.PositiveInfinity;
                }

                child.Measure(slotSize);

                return(new Size(
                           Math.Min(size.Width, child.DesiredSize.Width),
                           Math.Min(size.Height, child.DesiredSize.Height)
                           ));
            }

            return(new Foundation.Size(0, 0));
        }
Exemplo n.º 2
0
 protected override Foundation.Size ApplyChildStretch(Foundation.Size childSize, Foundation.Size slotSize, ViewType viewType)
 {
     //Item views in a grid layout shouldn't be stretched
     if (viewType == ViewType.Item)
     {
         return(childSize);
     }
     return(base.ApplyChildStretch(childSize, slotSize, viewType));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the AnchorPoint to be applied to the UIView's Layer,
        /// considering both UIElement's RenderTransformOrigin and Transform's Center (CenterX/CenterY).
        /// </summary>
        private Foundation.Point GetAnchorPoint(Foundation.Size size)
        {
            if (size.Width == 0 || size.Height == 0)
            {
                return(Origin);
            }

            var center = GetCenter();

            return(new Foundation.Point(
                       Origin.X + (center.X / size.Width),
                       Origin.Y + (center.Y / size.Height)
                       ));
        }
        protected override Foundation.Size ArrangeOverride(Foundation.Size finalSize)
        {
            var child = Content as UIElement;

            if (child != null)
            {
                var slotSize = finalSize;

                var desiredChildSize = child.DesiredSize;

                if (VerticalScrollBarVisibility != ScrollBarVisibility.Disabled)
                {
                    slotSize.Height = Math.Max(desiredChildSize.Height, finalSize.Height);
                }
                if (HorizontalScrollBarVisibility != ScrollBarVisibility.Disabled)
                {
                    slotSize.Width = Math.Max(desiredChildSize.Width, finalSize.Width);
                }

                child.Arrange(new Rect(new Point(0, 0), slotSize));
            }

            return(finalSize);
        }