Skip to content

Instantly share code, notes, and snippets.

@jonstodle
Created October 28, 2015 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonstodle/c37c7cac514521ca7d6b to your computer and use it in GitHub Desktop.
Save jonstodle/c37c7cac514521ca7d6b to your computer and use it in GitHub Desktop.
protected override Size ArrangeOverride(Size finalSize)
{
var columnWidth = finalSize.Width / MaximumColumns;
var posY = 0d;
var rowHeight = 0d;
var rowChildCount = 0;
foreach (var child in Children)
{
if (rowChildCount >= MaximumColumns)
{
// New row
rowChildCount = 0;
posY += rowHeight;
rowHeight = 0;
}
child.Arrange(new Rect(columnWidth * rowChildCount, posY, columnWidth, child.DesiredSize.Height));
// Get the height of the row, based on the talles row child
rowHeight = Math.Max(child.DesiredSize.Height, rowHeight);
rowChildCount++;
}
return finalSize;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment