Esempio n. 1
0
        private void CreateWindow(TileCollection tiles)
        {
            Width  = tiles.Width;
            Height = tiles.Height;

            for (var i = 0; i < tiles.Columns; i++)
            {
                MainGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }
            for (var i = 0; i < tiles.Rows; i++)
            {
                MainGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
            }

            for (var row = 0; row < tiles.Rows; row++)
            {
                for (var col = 0; col < tiles.Columns; col++)
                {
                    var tile = tiles.FirstOrDefault(t => t.Column == col && t.Row == row);
                    if (tile == null)
                    {
                        var id = tiles.Count > 0 ? tiles.Max(t => t.Id) + 1 : 0;
                        tile = new AppTile(id, col, row);
                        tiles.Add(tile);
                    }
                    var button = new TileButton(tile, this);
                    MainGrid.Children.Add(button);
                }
            }
        }