void AddColumn() { contentGrid.ColumnDefinitions.Add( new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) } ); for (int i = 0; i < rowCount; i++) { var box = new MathBox(); AttachEvents(box); box.SetValue(Grid.RowProperty, i); box.SetValue(Grid.ColumnProperty, columnCount); boxRows[i].Add(box); contentGrid.Children.Add(box); } columnCount++; }
void AddRow() { contentGrid.RowDefinitions.Add( new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) } ); var newRow = new List <MathBox>(); for (int i = 0; i < columnCount; i++) { var box = new MathBox(); AttachEvents(box); box.SetValue(Grid.RowProperty, rowCount); box.SetValue(Grid.ColumnProperty, i); newRow.Add(box); contentGrid.Children.Add(box); } boxRows.Add(newRow); rowCount++; }