private void CalculateRowColumnCount(Size availableSize, int count)
{
//Calculate how many rows/cols we need for the number of items
if (!double.IsPositiveInfinity(availableSize.Width))
currentColumnCount = (int)Math.Floor(availableSize.Width / ColumnWidth);
else
currentColumnCount = MaxColumnCount;
currentRowCount = (int)Math.Floor(availableSize.Height / RowHeight);
if (count > 0)
currentColumnCount = (int)Math.Min(Math.Ceiling(count / (double)currentRowCount), MaxColumnCount);
else
currentColumnCount = 0;
if (count < currentRowCount) currentRowCount = count;
}