I'm working on a project for school and I'm kind of stumped. I have a grid (10 columns and 5 rows) and I want to fill each cell with a rectangle.
The user will be able to specify how many cells are filled at runtime...
Here is the code I have written to draw a single rectangle in a specified cell ( (2,2) for testing purposes ):
[cpp]
public void CreateTempRectange()
{
Rectangle temp = new Rectangle();
temp.Height = ( (mainWindow.Height/5) - 10 );
temp.Width = ( (mainWindow.Width/10) - 5 );
temp.StrokeThickness = 1;
temp.Stroke = blackBrush;
temp.SetValue(Grid.RowProperty, 2);
temp.SetValue(Grid.ColumnProperty, 2);
myGrid.Children.Add(temp);
}
[/cpp]
Is there a way I can create a for loop to create a rectangle in each cell?
The user will be able to specify how many cells are filled at runtime...
Here is the code I have written to draw a single rectangle in a specified cell ( (2,2) for testing purposes ):
[cpp]
public void CreateTempRectange()
{
Rectangle temp = new Rectangle();
temp.Height = ( (mainWindow.Height/5) - 10 );
temp.Width = ( (mainWindow.Width/10) - 5 );
temp.StrokeThickness = 1;
temp.Stroke = blackBrush;
temp.SetValue(Grid.RowProperty, 2);
temp.SetValue(Grid.ColumnProperty, 2);
myGrid.Children.Add(temp);
}
[/cpp]
Is there a way I can create a for loop to create a rectangle in each cell?