Exemplo n.º 1
0
 public DataGridCellEditingCancelEventArgs(DataGridColumnBase dataGridColumn,
                                           DataGridRow dataGridRow,
                                           Control element,
                                           DataGridEditingTriggerInfo editingTriggerInfo) : base(dataGridColumn, dataGridRow, element)
 {
     this.EditingTriggerInfo = editingTriggerInfo;
 }
Exemplo n.º 2
0
        public override object PrepareCellEdit(DataGridEditingTriggerInfo editingTriggerInfo)
        {
            if (this._editingCheckBox != null)
            {
                bool?uneditedValue = this._editingCheckBox.IsChecked;
                if (editingTriggerInfo != null &&
                    editingTriggerInfo.MouseButtonEventArgs != null)
                {
                    // Editing was triggered by a mouse click
                    FrameworkElement checkBox = editingTriggerInfo.MouseButtonEventArgs.Source as FrameworkElement;
                    while (checkBox != null && !(checkBox is CheckBox))
                    {
                        checkBox = checkBox.Parent as FrameworkElement;
                    }
                    if (checkBox != null)
                    {
                        // User clicked the checkbox itself, let's toggle the IsChecked value
                        if (this._editingCheckBox.IsThreeState)
                        {
                            switch (this._editingCheckBox.IsChecked)
                            {
                            case false:
                                this._editingCheckBox.IsChecked = true;
                                break;

                            case true:
                                this._editingCheckBox.IsChecked = null;
                                break;

                            case null:
                                this._editingCheckBox.IsChecked = false;
                                break;
                            }
                        }
                        else
                        {
                            this._editingCheckBox.IsChecked = !this._editingCheckBox.IsChecked;
                        }
                    }
                }
                return(uneditedValue);
            }
            return(false);
        }
Exemplo n.º 3
0
 public override object PrepareCellEdit(DataGridEditingTriggerInfo editingTriggerInfo)
 {
     if (this._editingTextBox != null)
     {
         string uneditedText = this._editingTextBox.Text;
         int    len          = uneditedText.Length;
         if (editingTriggerInfo != null &&
             editingTriggerInfo.KeyEventArgs != null &&
             editingTriggerInfo.KeyEventArgs.Key == Key.F2)
         {
             // Put caret at the end of the text
             this._editingTextBox.Select(len, len);
         }
         else
         {
             // Select all text
             this._editingTextBox.Select(0, len);
         }
         return(uneditedText);
     }
     return(string.Empty);
 }
Exemplo n.º 4
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; 
        }
Exemplo n.º 5
0
        /// <summary>
        /// Enters editing mode for the current cell and current row (if they're not already in editing mode). 
        /// </summary>
        /// <param name="editingTriggerInfo">Provides information about the user gesture that caused the call to BeginEdit. Can be null.</param>
        /// <returns>True if operation was successful. False otherwise.</returns> 
        public bool BeginEdit(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);
 
            if (GetColumnEffectiveReadOnlyState(this.CurrentColumn))
            {
                // Current column is read-only 
                // 
                return false;
            } 
            if (editingTriggerInfo != null)
            {
                editingTriggerInfo.ContainsFocus = this.ContainsFocus; 
            }
            //
            return BeginCellEdit(editingTriggerInfo); 
        } 
Exemplo n.º 6
0
 public abstract object PrepareCellEdit(DataGridEditingTriggerInfo editingTriggerInfo);
Exemplo n.º 7
0
 public abstract object PrepareCellEdit(DataGridEditingTriggerInfo editingTriggerInfo); 
Exemplo n.º 8
0
 public override object PrepareCellEdit(DataGridEditingTriggerInfo editingTriggerInfo)
 { 
     if (this._editingCheckBox != null) 
     {
         bool? uneditedValue = this._editingCheckBox.IsChecked; 
         if (editingTriggerInfo != null &&
             editingTriggerInfo.MouseButtonEventArgs != null)
         { 
             // Editing was triggered by a mouse click
             FrameworkElement checkBox = editingTriggerInfo.MouseButtonEventArgs.Source as FrameworkElement;
             while (checkBox != null && !(checkBox is CheckBox)) 
             { 
                 checkBox = checkBox.Parent as FrameworkElement;
             } 
             if (checkBox != null)
             {
                 // User clicked the checkbox itself, let's toggle the IsChecked value 
                 if (this._editingCheckBox.IsThreeState)
                 {
                     switch (this._editingCheckBox.IsChecked) 
                     { 
                         case false:
                             this._editingCheckBox.IsChecked = true; 
                             break;
                         case true:
                             this._editingCheckBox.IsChecked = null; 
                             break;
                         case null:
                             this._editingCheckBox.IsChecked = false; 
                             break; 
                     }
                 } 
                 else
                 {
                     this._editingCheckBox.IsChecked = !this._editingCheckBox.IsChecked; 
                 }
             }
         } 
         return uneditedValue; 
     }
     return false; 
 }
Exemplo n.º 9
0
 public override object PrepareCellEdit(DataGridEditingTriggerInfo editingTriggerInfo)
 {
     if (this._editingTextBox != null) 
     { 
         string uneditedText = this._editingTextBox.Text;
         int len = uneditedText.Length; 
         if (editingTriggerInfo != null &&
             editingTriggerInfo.KeyEventArgs != null &&
             editingTriggerInfo.KeyEventArgs.Key == Key.F2) 
         {
             // Put caret at the end of the text
             this._editingTextBox.Select(len, len); 
         } 
         else
         { 
             // Select all text
             this._editingTextBox.Select(0, len);
         } 
         return uneditedText;
     }
     return string.Empty; 
 }