protected override void OnReallocate() { base.OnReallocate(); int margin = BorderVisible ? 1 : 0; var vwidth = vScrollBar.Visible ? vScrollBar.WidthRequest : 0D; var hheight = hScrollBar.Visible ? hScrollBar.HeightRequest : 0D; var childRectangle = new Xwt.Rectangle(Bounds.X + margin, Bounds.Y + margin, Bounds.Width - vwidth - margin * 2, Bounds.Height - hheight - margin * 2); if (vScrollBar.Visible) { double vChildTopHeight = -1; foreach (var child in positions) { if (child.Value == ChildPosition.Top) { SetChildBounds(child.Key, new Rectangle(childRectangle.RightInside(), childRectangle.Y + vChildTopHeight, Bounds.Width - vwidth, child.Key.HeightRequest)); vChildTopHeight += child.Key.HeightRequest; } } var v = vScrollBar is Scrollbar && hScrollBar.Visible ? hScrollBar.HeightRequest : 0; SetChildBounds(vScrollBar, new Rectangle(childRectangle.X + childRectangle.Width + margin, childRectangle.Y + vChildTopHeight, vwidth, Bounds.Height - v - vChildTopHeight - margin)); Vadjustment.Value = System.Math.Max(System.Math.Min(Vadjustment.UpperValue - Vadjustment.PageSize, Vadjustment.Value), Vadjustment.LowerValue); } if (hScrollBar.Visible) { var v = vScrollBar.Visible ? vScrollBar.WidthRequest : 0; SetChildBounds(hScrollBar, new Rectangle(Bounds.X, childRectangle.Y + childRectangle.Height + margin, Bounds.Width - v, hheight)); hScrollBar.Value = System.Math.Max(System.Math.Min(Hadjustment.UpperValue - Hadjustment.PageSize, hScrollBar.Value), Hadjustment.LowerValue); } }