public void AddColumn(int currentRow, int currentColumn, ColumnInsertLocation insertLocation) { PreventRecursiveUpdates = true; foreach (var row in TableSource) { var newCell = new CellContent(string.Empty); if (insertLocation == ColumnInsertLocation.Right) { row.Insert(currentColumn + 1, newCell); } else { row.Insert(currentColumn, newCell); } } PreventRecursiveUpdates = false; RepopulateChildren(TableSource); if (insertLocation == ColumnInsertLocation.Right) { SelectColumn(currentRow, currentColumn + 1); } else { SelectColumn(currentRow, currentColumn); } }
public void AddRow(int currentRow, int currentColumn, RowInsertLocation insertLocation) { var row = TableSource[currentRow] as ObservableCollection <CellContent>; if (row == null) { return; } PreventRecursiveUpdates = true; var newCell = new CellContent(string.Empty); if (insertLocation == RowInsertLocation.Below) { var newRow = new ObservableCollection <CellContent>(); for (int i = 0; i < row.Count; i++) { newRow.Add(new CellContent(string.Empty)); } TableSource.Insert(currentRow + 1, newRow); } else { var newRow = new ObservableCollection <CellContent>(); for (int i = 0; i < row.Count; i++) { newRow.Add(new CellContent(string.Empty)); } TableSource.Insert(currentRow, newRow); } PreventRecursiveUpdates = false; RepopulateChildren(TableSource); if (insertLocation == RowInsertLocation.Below) { SelectColumn(currentRow + 1, 0); } else { SelectColumn(currentRow, 0); } }