/// <summary> /// This virtual method is called when ApplicationCommands. Paste command is executed. /// </summary> /// <param name="args"></param> protected virtual void OnExecutedPaste(ExecutedRoutedEventArgs args) { Debug.WriteLine("The Events '<OnExecutedPaste>' Begin..."); // Parse the clipboard data. List <string[]> rowData = ClipboardHelper.ParseClipboardData(); if (rowData == null) { return; } // Call OnPastingCellClipboardContent for each cell. int minRowIndex = Items.IndexOf(CurrentItem); int maxRowIndex = Items.Count - 1; int minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0; int maxColumnDisplayIndex = Columns.Count - 1; int rowDataIndex = 0; for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++) { int columnDataIndex = 0; for (int j = minColumnDisplayIndex; j <= maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++) { DataGridColumn column = ColumnFromDisplayIndex(j); column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]); } } }
/// <summary> /// This virtual method is called when ApplicationCommands.Paste command is executed. /// </summary> /// <param name="args"></param> protected virtual void OnExecutedPaste(ExecutedRoutedEventArgs args) { Debug.WriteLine("OnExecutedPaste begin"); // parse the clipboard data List <string[]> rowData = ClipboardHelper.ParseClipboardData(); // call OnPastingCellClipboardContent for each cell //int nSelectedCells = int minRowIndex = Items.IndexOf(CurrentItem); int maxRowIndex = Items.Count - 1; int minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0; int maxColumnDisplayIndex = Columns.Count - 1; if (SelectedCells.Count > 1) { GetSelectionBounds(ref minRowIndex, ref maxRowIndex, ref minColumnDisplayIndex, ref maxColumnDisplayIndex); } int rowDataIndex = 0; for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++) { int columnDataIndex = 0; for (int j = minColumnDisplayIndex; j <= maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++) { DataGridColumn column = ColumnFromDisplayIndex(j); column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]); } } }
public void Paste() { // parse the clipboard data List <string[]> rowData = ClipboardHelper.ParseClipboardData(); if (rowData != null) { bool hasAddedNewRow = false; // call OnPastingCellClipboardContent for each cell int minRowIndex = Items.IndexOf(CurrentItem); int maxRowIndex = Items.Count - 1; int minColumnDisplayIndex = 0; int maxColumnDisplayIndex = Columns.Count - 1; int rowDataIndex = 0; for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++) { CurrentItem = Items[i]; BeginEditCommand.Execute(null, this); int columnDataIndex = 0; for (int j = minColumnDisplayIndex; j <= maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++) { DataGridColumn column = ColumnFromDisplayIndex(j); column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]); } CommitEditCommand.Execute(this, this); if (i == maxRowIndex) { maxRowIndex++; hasAddedNewRow = true; } } // update selection if (hasAddedNewRow) { UnselectAll(); UnselectAllCells(); CurrentItem = Items[minRowIndex]; if (SelectionUnit == DataGridSelectionUnit.FullRow) { SelectedItem = Items[minRowIndex]; } else if (SelectionUnit == DataGridSelectionUnit.CellOrRowHeader || SelectionUnit == DataGridSelectionUnit.Cell) { SelectedCells.Add(new DataGridCellInfo(Items[minRowIndex], Columns[minColumnDisplayIndex])); } } } }
// ****************************************************************** /// <summary> /// This virtual method is called when ApplicationCommands.Paste command is executed. /// </summary> /// <param name="target"></param> /// <param name="args"></param> protected virtual void OnExecutedPaste(object sender, ExecutedRoutedEventArgs args) { // parse the clipboard data List <string[]> rowData = ClipboardHelper.ParseClipboardData(); bool hasAddedNewRow = false; // call OnPastingCellClipboardContent for each cell int minRowIndex = Math.Max(Items.IndexOf(CurrentItem), 0); int maxRowIndex = Items.Count - 1; int minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0; int maxColumnDisplayIndex = Columns.Count - 1; int rowDataIndex = 0; for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++) { if (CanUserAddRows && i == maxRowIndex) { // add a new row to be pasted to ICollectionView cv = CollectionViewSource.GetDefaultView(Items); IEditableCollectionView iecv = cv as IEditableCollectionView; if (iecv != null) { hasAddedNewRow = true; iecv.AddNew(); if (rowDataIndex + 1 < rowData.Count) { // still has more items to paste, update the maxRowIndex maxRowIndex = Items.Count - 1; } } } else if (i == maxRowIndex) { continue; } int columnDataIndex = 0; for (int j = minColumnDisplayIndex; j < maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++) { DataGridColumn column = ColumnFromDisplayIndex(j); string propertyName = ((column as DataGridBoundColumn).Binding as Binding).Path.Path; object item = Items[i]; object value = rowData[rowDataIndex][columnDataIndex]; PropertyInfo pi = item.GetType().GetProperty(propertyName); if (pi != null) { object convertedValue = Convert.ChangeType(value, pi.PropertyType); item.GetType().GetProperty(propertyName).SetValue(item, convertedValue, null); } column.OnPastingCellClipboardContent(item, rowData[rowDataIndex][columnDataIndex]); } } }
/// <summary> /// 粘贴 /// </summary> private void ExecutedPaste(object sender, ExecutedRoutedEventArgs e) { try { List <string[]> rowData = _parseClipboardData(); if (rowData.Count < 1) { return; } var _currentCell = this.CurrentCell; if (_currentCell == null) { return; } int rowIndex = this.Items.IndexOf(_currentCell.Item); int columnIndex = _currentCell.Column.DisplayIndex; int rind = rowIndex; for (int i = 0; rowIndex < this.Items.Count && i < rowData.Count; ++i, ++rowIndex) { int columnind = columnIndex; for (int j = 0; j < rowData[i].Length && columnind < this.Columns.Count; ++j, ++columnind) { DataGridColumn colum = this.ColumnFromDisplayIndex(columnind); colum.OnPastingCellClipboardContent(this.Items[rowIndex], rowData[i][j].TrimEnd()); if (rowIndex > rind && columnind == columnIndex) { colum.OnPastingCellClipboardContent(this.Items[rowIndex], rowData[i][j].TrimEnd()); } } } } catch { } // 确保每次编辑结束之后更新数据 this.CommitEdit(); }
/// <summary> /// This virtual method is called when ApplicationCommands.Paste command is executed. /// </summary> /// <param name="args"></param> protected virtual void OnExecutedPaste(ExecutedRoutedEventArgs args) { if (CanClipboardPaste == false) { return; } // Parse the clipboard data List <string[]> data = ClipboardHelper.ParseClipboardData(); if (data == null) { return; } UnselectAll(); UnselectAllCells(); // Call OnPastingCellClipboardContent for each cell int minDispRow = Items.IndexOf(CurrentItem); int maxDispRow = Items.Count; int minDispCol = Columns.IndexOf(CurrentColumn); int maxDispCol = Columns.Count; int dispRow, dispCol, dataRow, dataCol; for (dispRow = minDispRow, dataRow = 0; dataRow < data.Count; dispRow++, dataRow++) { if (dispRow >= maxDispRow) { var itemsSourceList = ItemsSource as IList; var addValue = Activator.CreateInstance(Items[0].GetType()); maxDispRow++; itemsSourceList.Add(addValue); } BeginEditCommand.Execute(null, this); for (dispCol = minDispCol, dataCol = 0; dispCol < maxDispCol && dataCol < data[dataRow].Length; dispCol++, dataCol++) { DataGridColumn column = ColumnFromDisplayIndex(dispCol); column.OnPastingCellClipboardContent(Items[dispRow], data[dataRow][dataCol]); if (SelectionUnit == DataGridSelectionUnit.CellOrRowHeader || SelectionUnit == DataGridSelectionUnit.Cell) { SelectedCells.Add(new DataGridCellInfo(Items[dispRow], Columns[dispCol])); } } if (SelectionUnit == DataGridSelectionUnit.FullRow) { SelectedItems.Add(Items[dispRow]); } CommitEditCommand.Execute(this, this); } }
protected virtual void OnExecutedCopy(ExecutedRoutedEventArgs args) { // Now find all selected cells and construct the right value (not display value) // parse the clipboard data List <string[]> rowData = ClipboardHelper.ParseClipboardData(); // call OnPastingCellClipboardContent for each cell int minRowIndex = Items.IndexOf(CurrentItem); int maxRowIndex = Items.Count - 1; int minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0; int maxColumnDisplayIndex = Columns.Count - 1; int rowDataIndex = 0; bool hasAddedNewRow = false; for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++) { if (i == maxRowIndex) { maxRowIndex++; hasAddedNewRow = true; } int columnDataIndex = 0; for (int j = minColumnDisplayIndex; j <= maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++) { DataGridColumn column = ColumnFromDisplayIndex(j); column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]); } } if (hasAddedNewRow) { UnselectAll(); UnselectAllCells(); CurrentItem = Items[minRowIndex]; if (SelectionUnit == DataGridSelectionUnit.FullRow) { SelectedItem = Items[minRowIndex]; } else if (SelectionUnit == DataGridSelectionUnit.CellOrRowHeader || SelectionUnit == DataGridSelectionUnit.Cell) { SelectedCells.Add(new DataGridCellInfo(Items[minRowIndex], Columns[minColumnDisplayIndex])); } } }
/// <summary> /// This virtual method is called when ApplicationCommands.Paste command is executed. /// </summary> /// <param name="args"></param> protected virtual void OnExecutedPaste(ExecutedRoutedEventArgs args) { Debug.WriteLine("OnExecutedPaste begin"); // parse the clipboard data List <string[]> rowData = ClipboardHelper.ParseClipboardData(); if (rowData == null) { return; } // call OnPastingCellClipboardContent for each cell int minRowIndex = Items.IndexOf(CurrentItem); int maxRowIndex = Items.Count - 1; int minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0; int maxColumnDisplayIndex = Columns.Count - 1; int rowDataIndex = 0; for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++) { int columnDataIndex = 0; var strengthTrainingItemViewModel = (StrengthTrainingItemViewModel)Items[i]; for (int j = minColumnDisplayIndex; j < maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++) { DataGridColumn column = ColumnFromDisplayIndex(j); if (j == 1 /*ExerciseId column*/) { Guid exerciseId; if (Guid.TryParse(rowData[rowDataIndex][columnDataIndex], out exerciseId)) { strengthTrainingItemViewModel.Exercise = ExercisesReposidory.Instance.GetItem(exerciseId); } } else if (!column.IsReadOnly && (j < 2 || (!string.IsNullOrEmpty(rowData[rowDataIndex][columnDataIndex]) && !strengthTrainingItemViewModel.IsNew))) { column.OnPastingCellClipboardContent(strengthTrainingItemViewModel, rowData[rowDataIndex][columnDataIndex]); } } } RefreshItems(); }
// ****************************************************************** /// <summary> /// This virtual method is called when ApplicationCommands.Paste command is executed. /// </summary> /// <param name="target"></param> /// <param name="args"></param> protected virtual void OnExecutedPaste(object target, ExecutedRoutedEventArgs args) { // parse the clipboard data List <string[]> rowData = ClipboardHelper.ParseClipboardData(); // call OnPastingCellClipboardContent for each cell int minRowIndex = Items.IndexOf(CurrentItem); int maxRowIndex = Items.Count - 1; int minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0; int maxColumnDisplayIndex = Columns.Count - 1; int rowDataIndex = 0; for (int i = minRowIndex; i < maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++) { int columnDataIndex = 0; for (int j = minColumnDisplayIndex; j < maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++) { DataGridColumn column = ColumnFromDisplayIndex(j); column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]); } } }
protected virtual void OnExecutedPaste(ExecutedRoutedEventArgs args) { try { //Debug.WriteLine("OnExecutedPaste begin"); // parse the clipboard data object obj = this.DetailType; List <string[]> rowData = ClipboardHelper.ParseClipboardData(); //bool hasAddedNewRow = false; if (rowData != null) { // call OnPastingCellClipboardContent for each cell if (this.SelectedIndex != -1) { object item = null; if (CurrentItem == null) { item = this.Items[this.SelectedIndex];//Added by william at 2017-04-20 工具条中的命令找不至CurrentItem } else { item = CurrentItem; } //int minRowIndex = LoopNameCollection.IndexOf(CurrentItem); int minRowIndex = Items.IndexOf(item); int maxRowIndex = Items.Count - 1; int minColumnDisplayIndex; if (CurrentColumn != null) { minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0; } else { minColumnDisplayIndex = 0; } int maxColumnDisplayIndex = Columns.Count - 1; int rowDataIndex = 1; for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++) { #region 将数据粘贴至新增的行中 //if (CanUserAddRows) //{ // if (CanUserPasteToNewRows && CanUserAddRows && i == maxRowIndex) // { // // add a new row to be pasted to // ICollectionView cv = CollectionViewSource.GetDefaultView(Items); // IEditableCollectionView iecv = cv as IEditableCollectionView; // if (iecv != null) // { // // hasAddedNewRow = true; // iecv.AddNew(); // if (rowDataIndex + 1 < rowData.Count) // { // // still has more items to paste, update the maxRowIndex // maxRowIndex = Items.Count - 1; // } // } // } // else if (i == maxRowIndex) // { // continue; // } //} #endregion int columnDataIndex = 0; for (int j = minColumnDisplayIndex; j <= maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++) { DataGridColumn column = ColumnFromDisplayIndex(j); if (column.Header.ToString() != "编号" && column.Header.ToString() != "编码" && column.Header.ToString() != "输出组号" && column.Header.ToString() != "手键号") { if (column.Visibility == Visibility.Visible) { column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]); } else { columnDataIndex = columnDataIndex - 1; } } } UpdateToModel(this.DetailType, Items[i], rowData[0], rowData[rowDataIndex]); } } else { int rowDataIndex = 1; if (this.SelectedCells != null) //更新列信息 { bool singleColumnFlag = true; //仅允许选择一列进行粘贴 if (SelectedCells.Count > 2) { int columnIndex = this.SelectedCells[0].Column.DisplayIndex; DataGridColumn column1 = ColumnFromDisplayIndex(columnIndex); columnIndex = this.SelectedCells[1].Column.DisplayIndex; DataGridColumn column2 = ColumnFromDisplayIndex(columnIndex); if (column1.Header != column2.Header) { singleColumnFlag = false; } } if (singleColumnFlag) { for (int i = 0; i < this.SelectedCells.Count; i++) { object item = this.SelectedCells[i].Item; int columnIndex = this.SelectedCells[i].Column.DisplayIndex; DataGridColumn column = ColumnFromDisplayIndex(columnIndex); if (column.Visibility == Visibility.Visible) { if (column.Header.ToString() == rowData[0][0]) //粘贴列与复制列为同一列 { column.OnPastingCellClipboardContent(item, rowData[rowDataIndex][0]); //固定为1列 UpdateToModel(this.DetailType, item, rowData[0], rowData[rowDataIndex]); } else { break; } } //((EditableLinkageConfigMixed)this.SelectedCells[0].Item).ID } } } } #region 更新选中区域 //if (hasAddedNewRow) //{ // UnselectAll(); // UnselectAllCells(); // CurrentItem = Items[minRowIndex]; // if (SelectionUnit == DataGridSelectionUnit.FullRow) // { // SelectedItem = Items[minRowIndex]; // } // else if (SelectionUnit == DataGridSelectionUnit.CellOrRowHeader || // SelectionUnit == DataGridSelectionUnit.Cell) // { // SelectedCells.Add(new DataGridCellInfo(Items[minRowIndex], Columns[minColumnDisplayIndex])); // } //} #endregion } } catch (Exception ex) { } }
protected virtual void OnExecutedPaste(ExecutedRoutedEventArgs args) { // Debug.WriteLine("OnExecutedPaste begin"); // parse the clipboard data List <string[]> rowData = new List <string[]>();// ClipboardHelper.ParseClipboardData(); string[] color = { "red", "black", "yellow" }; rowData.Add(color); bool hasAddedNewRow = false; // call OnPastingCellClipboardContent for each cell int minRowIndex = Items.IndexOf(CurrentItem); int maxRowIndex = Items.Count - 1; int minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0; int maxColumnDisplayIndex = Columns.Count - 1; int rowDataIndex = 0; for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++) { #region 将数据粘贴至新增的行中 if (CanUserPasteToNewRows && CanUserAddRows && i == maxRowIndex) { // add a new row to be pasted to ICollectionView cv = CollectionViewSource.GetDefaultView(Items); IEditableCollectionView iecv = cv as IEditableCollectionView; if (iecv != null) { hasAddedNewRow = true; iecv.AddNew(); if (rowDataIndex + 1 < rowData.Count) { // still has more items to paste, update the maxRowIndex maxRowIndex = Items.Count - 1; } } } else if (i == maxRowIndex) { continue; } #endregion int columnDataIndex = 0; for (int j = minColumnDisplayIndex; j < maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++) { DataGridColumn column = ColumnFromDisplayIndex(j); column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]); } } #region 更新选中区域 // update selection if (hasAddedNewRow) { UnselectAll(); UnselectAllCells(); CurrentItem = Items[minRowIndex]; if (SelectionUnit == DataGridSelectionUnit.FullRow) { SelectedItem = Items[minRowIndex]; } else if (SelectionUnit == DataGridSelectionUnit.CellOrRowHeader || SelectionUnit == DataGridSelectionUnit.Cell) { SelectedCells.Add(new DataGridCellInfo(Items[minRowIndex], Columns[minColumnDisplayIndex])); } } #endregion }
/// <summary> /// This virtual method is called when ApplicationCommands.Paste command is executed. /// </summary> /// <param name="target"></param> /// <param name="args"></param> protected virtual void OnExecutedPaste(object target, ExecutedRoutedEventArgs args) { if (ExecutePasteEvent != null) { ExecutePasteEvent(target, args); if (args.Handled) { return; } } // parse the clipboard data List <string[]> rowData = ClipboardHelper.ParseClipboardData(); bool hasAddedNewRow = false; // call OnPastingCellClipboardContent for each cell int minRowIndex = Items.IndexOf(CurrentItem); int maxRowIndex = Items.Count - 1; int minColumnDisplayIndex = (SelectionUnit != DataGridSelectionUnit.FullRow) ? Columns.IndexOf(CurrentColumn) : 0; int maxColumnDisplayIndex = Columns.Count - 1; int rowDataIndex = 0; for (int i = minRowIndex; i <= maxRowIndex && rowDataIndex < rowData.Count; i++, rowDataIndex++) { if (i < Items.Count) { CurrentItem = Items[i]; BeginEditCommand.Execute(null, this); int columnDataIndex = 0; for (int j = minColumnDisplayIndex; j <= maxColumnDisplayIndex && columnDataIndex < rowData[rowDataIndex].Length; j++, columnDataIndex++) { DataGridColumn column = ColumnFromDisplayIndex(j); column.OnPastingCellClipboardContent(Items[i], rowData[rowDataIndex][columnDataIndex]); //column.OnPastingCellClipboardContent( } CommitEditCommand.Execute(this, this); if (i == maxRowIndex) { maxRowIndex++; hasAddedNewRow = true; } } } // update selection if (hasAddedNewRow) { UnselectAll(); UnselectAllCells(); CurrentItem = Items[minRowIndex]; if (SelectionUnit == DataGridSelectionUnit.FullRow) { SelectedItem = Items[minRowIndex]; } else if (SelectionUnit == DataGridSelectionUnit.CellOrRowHeader || SelectionUnit == DataGridSelectionUnit.Cell) { SelectedCells.Add(new DataGridCellInfo(Items[minRowIndex], Columns[minColumnDisplayIndex])); } } }
// ****************************************************************** /// <summary> /// This virtual method is called when ApplicationCommands.Paste command is executed. /// </summary> /// <param name="target"></param> /// <param name="args"></param> protected virtual void OnExecutedPaste(object target, ExecutedRoutedEventArgs args) { if (ExecutePasteEvent != null) { ExecutePasteEvent(target, args); if (args.Handled) { return; } } // parse the clipboard data [row][column] List <string[]> clipboardData = ClipboardHelper.ParseClipboardData(); bool hasAddedNewRow = false; #if DEBUG StringBuilder sb = new StringBuilder(); #endif int minRowIndex = Items.IndexOf(CurrentItem); int maxRowIndex = Items.Count - 1; int startIndexOfDisplayCol = (SelectionUnit != DataGridSelectionUnit.FullRow) ? CurrentColumn.DisplayIndex : 0; int clipboardRowIndex = 0; for (int i = minRowIndex; i <= maxRowIndex && clipboardRowIndex < clipboardData.Count; i++, clipboardRowIndex++) { if (i < this.Items.Count) { CurrentItem = Items[i]; BeginEditCommand.Execute(null, this); int clipboardColumnIndex = 0; for (int j = startIndexOfDisplayCol; clipboardColumnIndex < clipboardData[clipboardRowIndex].Length; j++, clipboardColumnIndex++) { // DataGridColumn column = ColumnFromDisplayIndex(j); DataGridColumn column = null; foreach (DataGridColumn columnIter in this.Columns) { if (columnIter.DisplayIndex == j) { column = columnIter; break; } } column?.OnPastingCellClipboardContent(Items[i], clipboardData[clipboardRowIndex][clipboardColumnIndex]); #if DEBUG sb.AppendFormat("{0,-10}", clipboardData[clipboardRowIndex][clipboardColumnIndex]); sb.Append(" - "); #endif } CommitEditCommand.Execute(this, this); if (i == maxRowIndex) { maxRowIndex++; hasAddedNewRow = true; } } #if DEBUG sb.Clear(); #endif } // update selection if (hasAddedNewRow) { UnselectAll(); UnselectAllCells(); CurrentItem = Items[minRowIndex]; if (SelectionUnit == DataGridSelectionUnit.FullRow) { SelectedItem = Items[minRowIndex]; } else if (SelectionUnit == DataGridSelectionUnit.CellOrRowHeader || SelectionUnit == DataGridSelectionUnit.Cell) { SelectedCells.Add(new DataGridCellInfo(Items[minRowIndex], Columns[startIndexOfDisplayCol])); } } }