public override Rectangle Arrange(Rectangle availableSpace) { double totalHeight = 0; double availableWidth = availableSpace.Width; double currentRowHeight = 0; foreach (var child in children) { var size = child.Measure(new Size(availableSpace.Width, availableSpace.Height)); if (size.Width > availableWidth) { //break and start a new row totalHeight += currentRowHeight; child.Arrange(new Rectangle(0, totalHeight, size.Width, size.Height)); availableWidth = availableSpace.Width - size.Width; currentRowHeight = size.Height; } else { child.Arrange(new Rectangle(availableSpace.Width - availableWidth, totalHeight, size.Width, size.Height)); //add to current row availableWidth -= size.Width; currentRowHeight = Math.Max(currentRowHeight, size.Height); } } Space = availableSpace; return availableSpace; }
public override Rectangle Arrange(Rectangle availableSpace) { Space = availableSpace; return availableSpace; }