protected override Size MeasureOverride(Size availableSize)
{
if (ItemsSource == null)
return new Size(0, 0);
var list = (ItemsSource as IEnumerable).OfType<object>().ToList();
int count = list.Count;
CalculateRowColumnCount(availableSize, count);
foreach (var item in Children)
{
if (item is Callisto.Controls.LiveTile)
item.Measure(new Size(ColumnWidth * 2, RowHeight * 2));
else
item.Measure(new Size(ColumnWidth, RowHeight));
}
//If this is an incremental loading datasource, see if we can get enough to fill up and show more... tile.
if (ItemsSource is Windows.UI.Xaml.Data.ISupportIncrementalLoading)
{
var maxTileSpace = Math.Min(MaxColumnCount, Math.Ceiling(availableSize.Width / ColumnWidth)) * Math.Ceiling(availableSize.Height / RowHeight);
if (count <= maxTileSpace)
{
var iloading = (ItemsSource as Windows.UI.Xaml.Data.ISupportIncrementalLoading);
if (iloading.HasMoreItems)
{
var loadmoreTask = iloading.LoadMoreItemsAsync((uint)maxTileSpace + 1);
}
}
}
return new Size(currentColumnCount * ColumnWidth, currentRowCount * RowHeight);
}