Reputation: 9926
I want to set Grid Raw number & Grid Column number dynamically according to a parameter that I will get.
How can I do it ?
Upvotes: 0
Views: 328
Reputation: 526
Use this:
private void SetGridRowColumnNumber(Grid grid, int rowCount, int columnCount)
{
grid.RowDefinitions.Clear();
grid.ColumnDefinitions.Clear();
for (int i = 0; i < rowCount; i++)
{
grid.RowDefinitions.Add(new RowDefinition());
}
for (int i = 0; i < columnCount; i++)
{
grid.ColumnDefinitions.Add(new ColumnDefinition());
}
}
please let me know if this didn't help.
Upvotes: 1