Created
October 28, 2015 11:07
-
-
Save jonstodle/c37c7cac514521ca7d6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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