public override Size MeasureOverride(IPanelAdapter adapter, Size availaibleSize) { if (adapter.ChildrenCount < 1) { return(new Size(1, 1)); } // measure the first Child adapter.Measure(0, availaibleSize); var firstSize = adapter.GetDesiredSize(0); for (int i = 1; i < adapter.ChildrenCount; i++) { adapter.Measure(i, firstSize); } return(firstSize); }
public override Size MeasureOverride(IPanelAdapter adapter, Size availaibleSize) { measurements.Clear(); var cellSize = new Size(); for (int i = 0; i < adapter.ChildrenCount; i++) { if (i % Columns == 0) { cellSize = new Size(availaibleSize.Width / Columns, availaibleSize.Height - measurements.Sum(j => j.RowHeight)); measurements.Add(new MeasurementRowHeight()); } adapter.Measure(i, cellSize); measurements.Last().AddItem(i, adapter.GetDesiredSize(i).Height); } return(new Size(availaibleSize.Width, measurements.Sum(i => i.RowHeight))); }
public override Size ArrangeOverride(IPanelAdapter adapter, Size finalSize) { if (adapter.ChildrenCount < 1) { return(finalSize); } var desiredSize = adapter.GetDesiredSize(0); var finalRect = new Rect( new Point((finalSize.Width - desiredSize.Width) / 2, (finalSize.Height - desiredSize.Height) / 2), desiredSize); var adjustedRect = ApplyOffset ? new Rect(OffsetPoint(finalRect, Offset.Left, Offset.Top), OffsetPoint(finalRect, Offset.Right, Offset.Bottom)) : finalRect; for (int i = 0; i < adapter.ChildrenCount; i++) { adapter.Arrange(i, i == 0 ? finalRect : adjustedRect); } return(finalSize); }