internal static void EndEditHelper( DataGridContext dataGridContext ) { DataGridControl dataGridControl = dataGridContext.DataGridControl; if( !dataGridControl.IsBeingEdited ) return; if( !dataGridContext.IsContainingItem( dataGridContext.DataGridControl.CurrentItemInEdition ) ) throw new InvalidOperationException( "An attempt was made to call the EndEdit method of an item that is not part of the specified context." ); DependencyObject container = dataGridContext.GetContainerFromItem( dataGridControl.m_currentItemInEdition ); //if the item is realized, then I could call the EndEdit() directly on the container. if( container != null ) { Row row = Row.FromContainer( container ); if( row != null ) row.EndEdit(); //not a row, then not editable. } //if the container is not realized, then I need to set things up so that when the container is realized, it's gonna resume edition. else { DataGridControl.ProcessUnrealizedEndEdit( dataGridContext ); } }
internal static void BeginEditHelper( DataGridContext dataGridContext, object item ) { DataGridControl dataGridControl = dataGridContext.DataGridControl; if( dataGridControl.IsBeingEdited ) return; if( item == null ) return; if( !dataGridContext.IsContainingItem( item ) ) throw new InvalidOperationException( "An attempt was made to call the BeginEdit method of an item that is not part of the specified context." ); DependencyObject container = dataGridContext.GetContainerFromItem( item ); //if the item is realized, then I could call the BeginEdit() directly on the container. if( container != null ) { Row row = Row.FromContainer( container ); if( row != null ) row.BeginEdit(); //not a row, then not editable. } //if the container is not realized, then I need to set things up so that when the container is realized, it's gonna resume edition. else { dataGridContext.DataGridControl.UpdateCurrentRowInEditionCellStates( null, item ); dataGridContext.DataGridControl.BringItemIntoView( item ); } }