public void BuildTiles(IEnumerable <object> tiles)
{
try
{
if (tiles == null || tiles.Count() == 0)
{
Children?.Clear();
}
// Wipe out the previous row definitions if they're there.
RowDefinitions?.Clear();
var enumerable = tiles as IList ?? tiles.ToList();
var numberOfRows = Math.Ceiling(enumerable.Count / (float)MaxColumns);
for (var i = 0; i < numberOfRows; i++)
{
RowDefinitions?.Add(new RowDefinition {
Height = TileHeight
});
}
for (var index = 0; index < enumerable.Count; index++)
{
var column = index % MaxColumns;
var row = (int)Math.Floor(index / (float)MaxColumns);
var tile = BuildTile(enumerable[index]);
Children?.Add(tile, column, row);
}
}
catch { // can throw exceptions if binding upon disposal
}
}