コード例 #1
0
 internal void OnCommittingNewItem(DataGridCommittingNewItemEventArgs e)
 {
     if (this.CommittingNewItem != null)
     {
         this.CommittingNewItem(this, e);
     }
 }
コード例 #2
0
        public override void CommitNew()
        {
            // We are not calling base since the intended behavior is quite different with Virtualizing collection views.
            object currentAddItem = this.CurrentAddItem;

            if (currentAddItem == null)
            {
                return;
            }

            DataGridCommittingNewItemEventArgs committingNewItemEventArgs =
                new DataGridCommittingNewItemEventArgs(this, currentAddItem, false);

            this.RootDataGridCollectionViewBase.OnCommittingNewItem(committingNewItemEventArgs);

            if (committingNewItemEventArgs.Cancel)
            {
                throw new DataGridException("CommitNew was canceled.");
            }

            if (!committingNewItemEventArgs.Handled)
            {
                throw new InvalidOperationException("When manually handling the item-insertion process the CreatingNewItem, CommittingNewItem, and CancelingNewItem events must all be handled.");
            }

            // Contrarily to the data bound collection views, we do not care about the new index or new count since we will enqueue a Refresh operation.

            this.SetCurrentAddNew(null, -1);

            this.ExecuteOrQueueSourceItemOperation(new DeferredOperation(DeferredOperation.DeferredOperationAction.Refresh, -1, null));
        }