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--;
            }
        }
Example #2
0
 /// <summary>
 /// Inserts the child node.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="node">The node.</param>
 /// <returns></returns>
 public bool InsertChildNode(int index, SceneNode node)
 {
     if (node == null || node.IsAttached || itemHashSet.ContainsKey(node.GUID))
     {
         return(false);
     }
     itemHashSet.Add(node.GUID, node);
     ItemsInternal.Insert(index, node);
     node.Parent = this;
     if (IsAttached)
     {
         node.Attach(EffectsManager);
         InvalidateSceneGraph();
     }
     ChildNodeAdded?.Invoke(this, new OnChildNodeChangedArgs(node, Operation.Add));
     return(true);
 }