protected override void InsertItem(int columnIndex, DataGridColumn dataGridColumn)
        {
            try
            {
                _owningGrid.NoCurrentCellChangeCount++;
                if (_owningGrid.InDisplayIndexAdjustments)
                {
                    // We are within columns display indexes adjustments. We do not allow changing the column collection while adjusting display indexes.
                    throw DataGridError.DataGrid.CannotChangeColumnCollectionWhileAdjustingDisplayIndexes();
                }
                if (dataGridColumn == null)
                {
                    throw new ArgumentNullException("dataGridColumn");
                }

                int columnIndexWithFiller = columnIndex;
                if (dataGridColumn != RowGroupSpacerColumn && RowGroupSpacerColumn.IsRepresented)
                {
                    columnIndexWithFiller++;
                }

                // get the new current cell coordinates
                DataGridCellCoordinates newCurrentCellCoordinates = _owningGrid.OnInsertingColumn(columnIndex, dataGridColumn);

                // insert the column into our internal list
                ItemsInternal.Insert(columnIndexWithFiller, dataGridColumn);
                dataGridColumn.Index      = columnIndexWithFiller;
                dataGridColumn.OwningGrid = _owningGrid;
                dataGridColumn.RemoveEditingElement();
                if (dataGridColumn.IsVisible)
                {
                    VisibleEdgedColumnsWidth += dataGridColumn.ActualWidth;
                }

                // continue with the base insert
                _owningGrid.OnInsertedColumn_PreNotification(dataGridColumn);
                _owningGrid.OnColumnCollectionChanged_PreNotification(true /*columnsGrew*/);

                if (dataGridColumn != RowGroupSpacerColumn)
                {
                    base.InsertItem(columnIndex, dataGridColumn);
                }
                _owningGrid.OnInsertedColumn_PostNotification(newCurrentCellCoordinates, dataGridColumn.DisplayIndex);
                _owningGrid.OnColumnCollectionChanged_PostNotification(true /*columnsGrew*/);
            }
            finally
            {
                _owningGrid.NoCurrentCellChangeCount--;
            }
        }
        private void RemoveItemPrivate(int columnIndex, bool isSpacer)
        {
            try
            {
                _owningGrid.NoCurrentCellChangeCount++;

                if (_owningGrid.InDisplayIndexAdjustments)
                {
                    // We are within columns display indexes adjustments. We do not allow changing the column collection while adjusting display indexes.
                    throw DataGridError.DataGrid.CannotChangeColumnCollectionWhileAdjustingDisplayIndexes();
                }

                int columnIndexWithFiller = columnIndex;
                if (!isSpacer && RowGroupSpacerColumn.IsRepresented)
                {
                    columnIndexWithFiller++;
                }

                DataGridColumn          dataGridColumn            = ItemsInternal[columnIndexWithFiller];
                DataGridCellCoordinates newCurrentCellCoordinates = _owningGrid.OnRemovingColumn(dataGridColumn);
                ItemsInternal.RemoveAt(columnIndexWithFiller);
                if (dataGridColumn.IsVisible)
                {
                    VisibleEdgedColumnsWidth -= dataGridColumn.ActualWidth;
                }
                dataGridColumn.OwningGrid = null;
                dataGridColumn.RemoveEditingElement();

                // continue with the base remove
                _owningGrid.OnRemovedColumn_PreNotification(dataGridColumn);
                _owningGrid.OnColumnCollectionChanged_PreNotification(false /*columnsGrew*/);
                if (!isSpacer)
                {
                    base.RemoveItem(columnIndex);
                }
                _owningGrid.OnRemovedColumn_PostNotification(newCurrentCellCoordinates);
                _owningGrid.OnColumnCollectionChanged_PostNotification(false /*columnsGrew*/);
            }
            finally
            {
                _owningGrid.NoCurrentCellChangeCount--;
            }
        }
 public DataGridCellCoordinates(DataGridCellCoordinates dataGridCellCoordinates) : this(dataGridCellCoordinates.ColumnIndex, dataGridCellCoordinates.Slot)
 {
 }