public void CreateGrooveBuilderGrid(FrameworkElement context, Grid grid, IGridDimensions gridDimensions) { ResetGrid(context, grid); gridDimensions.CreateDefinitions(grid, new GridLength(1, GridUnitType.Star)); int loopPosition = 1; // Traverse the columns and rows, populating each with borders. for (int row = 0; row < gridDimensions.Rows; row++) { for (int column = 0; column < gridDimensions.Columns; column++) { if (gridDimensions.IsPositionAllowed(row, column)) { GrooveContainer grooveContainer = CreateGrooveContainer(context, loopPosition); Grid.SetRow(grooveContainer, row); Grid.SetColumn(grooveContainer, column); grid.Children.Add(grooveContainer); loopPosition++; } } } }
public MagicBox(Grid magicBoxGrid, List <GrooveTagItem> tagItem, IGridDimensions gridDimensions) { grooveTagItems = tagItem; gridDimensions.CreateDefinitions(magicBoxGrid, GridLength.Auto); int count = 0; for (int row = 0; row < gridDimensions.Rows; row++) { for (int column = 0; column < gridDimensions.Columns; column++) { count++; if (count > grooveTagItems.Count) { return; } GrooveTagItem grooveTagItem = grooveTagItems[count - 1]; Grid.SetRow(grooveTagItem, row); Grid.SetColumn(grooveTagItem, column); magicBoxGrid.Children.Add(grooveTagItem); } } }