示例#1
0
        private bool BeginCellEdit(DataGridEditingTriggerInfo editingTriggerInfo) 
        {
            // 
            if (this.CurrentColumnIndex == -1 || !GetRowSelection(this.CurrentRowIndex))
            {
                // 
                return false;
            }
 
            Debug.Assert(this.CurrentColumnIndex >= 0); 
            Debug.Assert(this.CurrentColumnIndex < this.Columns.Count);
            Debug.Assert(this.CurrentRowIndex >= -1); 
            Debug.Assert(this.CurrentRowIndex < this._rowCount);
            Debug.Assert(this._editingRow == null || this.EditingRowIndex == this.CurrentRowIndex);
            Debug.Assert(!GetColumnEffectiveReadOnlyState(this.CurrentColumn)); 
            Debug.Assert(this.CurrentColumn.Visibility == Visibility.Visible);

            if (this._editingColumnIndex != -1) 
            { 
                // Current cell is already in edit mode
                Debug.Assert(this._editingColumnIndex == this.CurrentColumnIndex); 
                //
                return true;
            } 

            //
 
 

 


 
            DataGridRow dataGridRow = this._editingRow;
            if (dataGridRow == null)
            { 
                if (IsRowDisplayed(this.CurrentRowIndex)) 
                {
                    dataGridRow = GetDisplayedRow(this.CurrentRowIndex); 
                }
                else
                { 
                    dataGridRow = GenerateRow(this.CurrentRowIndex);
                }
            } 
            Debug.Assert(dataGridRow != null); 
            DataGridCell dataGridCell = dataGridRow.Cells[this.CurrentColumnIndex];
            DataGridCellEditingCancelEventArgs e = new DataGridCellEditingCancelEventArgs(this.CurrentColumn, dataGridRow, dataGridCell.Content as FrameworkElement, editingTriggerInfo); 
            OnBeginningCellEdit(e);
            if (e.Cancel)
            { 
                //
                return false;
            } 
 
            if (this._editingRow == null && !BeginRowEdit(dataGridRow))
            { 
                //
                return false;
            } 
            Debug.Assert(this._editingRow != null);
            Debug.Assert(this.EditingRowIndex == this.CurrentRowIndex);
 
            this._editingColumnIndex = this.CurrentColumnIndex; 
            this._editingTriggerInfo = editingTriggerInfo;
            this._editingRow.Cells[this.CurrentColumnIndex].ApplyCellState(true /*animate*/); 
            PopulateCellContent(false /*forceTemplating*/, true /*isCellEdited*/, this.CurrentColumn, dataGridRow, dataGridCell);
            //
            return true; 
        }
示例#2
0
 /// <summary> 
 /// Raises the BeginningCellEdit event. 
 /// </summary>
 protected virtual void OnBeginningCellEdit(DataGridCellEditingCancelEventArgs e) 
 {
     EventHandler<DataGridCellEditingCancelEventArgs> handler = this.BeginningCellEdit;
     if (handler != null) 
     {
         handler(this, e);
     } 
 }