Example #1
0
        private DataGridDataErrorEventArgs CommitCellEditPrivate()
        {
            if (this._editingColumnIndex == -1) 
            {
                return null;
            } 
            Debug.Assert(this._editingColumnIndex >= 0); 
            Debug.Assert(this._editingColumnIndex < this.ColumnsItemsInternal.Count);
            Debug.Assert(this._editingRow != null); 

            DataGridDataErrorEventArgs dataError = null;
            DataGridColumnBase dataGridColumn = this.ColumnsItemsInternal[this._editingColumnIndex]; 
            FrameworkElement element = this._editingRow.Cells[this._editingColumnIndex].Content as FrameworkElement;
            DataGridCellCancelEventArgs e = new DataGridCellCancelEventArgs(dataGridColumn, this._editingRow, element);
            OnCommittingCellEdit(e); 
            if (e.Cancel) 
            {
                dataError = new DataGridDataErrorEventArgs(null, this.CurrentColumn, this._editingRow); 
                dataError.Cancel = true;
                return dataError;
            } 

            // Write the new cell value into the backend for non-bound cells.
            DataGridBoundColumnBase dataGridBoundColumn = dataGridColumn as DataGridBoundColumnBase; 
            try 
            {
                if (dataGridBoundColumn == null) 
                {
                    //
 
                    OnCommitCellEdit(new DataGridCellEventArgs(dataGridColumn, this._editingRow, element));
                }
            } 
            catch (Exception ex) 
            {
                dataError = new DataGridDataErrorEventArgs(ex, this.CurrentColumn, this._editingRow); 
                OnDataError(dataError);
                return dataError;
            } 
            return null;
        }
Example #2
0
 /// <summary>
 /// Raises the CommittingCellEdit event.
 /// </summary> 
 protected virtual void OnCommittingCellEdit(DataGridCellCancelEventArgs e)
 {
     EventHandler<DataGridCellCancelEventArgs> handler = this.CommittingCellEdit; 
     if (handler != null) 
     {
         handler(this, e); 
     }
 }