/// <summary> /// Create the grid with specified rows and columns. /// </summary> /// <returns>Returns the newly created grid. </returns> private GridLayout CreateGrid() { GridLayout grid = new GridLayout(); _gridSize = (GridSize)_gridSize.DeepCopy(); _gridSize.Sealed = true; int[] gridSize = (int[])_gridSize; //add rows and columns int rows = gridSize[0]; for (int i = 0; i < rows; i++) { grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); } int columns = gridSize[1]; for (int i = 0; i < columns; i++) { grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); } //TODO: change in style? grid.ChildMargin = new Thickness(10); _log.Debug($"The {nameof(GridLayout)} has been created with the size {gridSize[0]}, {gridSize[1]}. From now on it cannot be modified."); return(grid); }