Skip to content

Instantly share code, notes, and snippets.

@jonstodle
Created October 29, 2015 18:55
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/6d6cebdb00c8c9cdd94a to your computer and use it in GitHub Desktop.
Save jonstodle/6d6cebdb00c8c9cdd94a to your computer and use it in GitHub Desktop.
protected override Size MeasureOverride(Size availableSize)
{
var finalSize = new Size { Width = availableSize.Width };
var rowHeight = 0d;
var posX = 0d;
foreach (var child in Children)
{
child.Measure(availableSize);
posX += child.DesiredSize.Width;
if (posX > availableSize.Width)
{
posX = child.DesiredSize.Width;
finalSize.Height += rowHeight;
rowHeight = child.DesiredSize.Height;
}
else
{
rowHeight = Math.Max(child.DesiredSize.Height, rowHeight);
}
}
finalSize.Height += rowHeight;
return finalSize;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment