/// <inheritdoc/> protected override Size2D ArrangeOverride(Size2D finalSize, ArrangeOptions options) { foreach (var child in Children) { var left = GetLeft(child); var top = GetTop(child); var right = GetRight(child); var bottom = GetBottom(child); if (Double.IsNaN(left) && Double.IsNaN(right)) { left = 0; } if (Double.IsNaN(top) && Double.IsNaN(bottom)) { top = 0; } var validLeft = LayoutUtil.GetValidMeasure(left, 0); var validTop = LayoutUtil.GetValidMeasure(top, 0); var validRight = LayoutUtil.GetValidMeasure(right, 0); var validBottom = LayoutUtil.GetValidMeasure(bottom, 0); var childWidth = Math.Min(child.DesiredSize.Width, finalSize.Width - (validLeft + validRight)); var childHeight = Math.Min(child.DesiredSize.Height, finalSize.Height - (validTop + validBottom)); if (!Double.IsNaN(left) && !Double.IsNaN(right)) { childWidth = Math.Max(0, finalSize.Width - (left + right)); } if (!Double.IsNaN(top) && !Double.IsNaN(bottom)) { childHeight = Math.Max(0, finalSize.Height - (top + bottom)); } var childX = 0.0; var childY = 0.0; if (!Double.IsNaN(left)) { childX = left; } if (!Double.IsNaN(top)) { childY = top; } if (!Double.IsNaN(right)) { childX = finalSize.Width - (right + childWidth); } if (!Double.IsNaN(bottom)) { childY = finalSize.Height - (bottom + childHeight); } child.Arrange(new RectangleD(childX, childY, childWidth, childHeight)); } return(finalSize); }