public override Size GetPreferredSize(ViewLayoutContext context)
{
Debug.Assert(context != null);
// Ensure that the correct number of children are created
SyncChildren();
Size preferredSize = Size.Empty;
// Find size of the first item, if there is one
if (Count > 0)
{
// Ask child for it's own preferred size
preferredSize = this[0].GetPreferredSize(context);
// Find preferred size from the preferred item size
int lineItems = Math.Max(1, _lineItems);
preferredSize.Width *= lineItems;
preferredSize.Height *= (Count + (lineItems - 1)) / lineItems;
}
// Add on the requests padding
preferredSize.Width += _padding.Horizontal;
preferredSize.Height += _padding.Vertical;
return preferredSize;
}