I am working on an application that validates cells in DataGrid in WPF. If there is an error in a cell, for example, I am making the cell editable. However, the changed data is not getting binded to the data-grid's ItemsSource. The following is the code that I am using to make the cell editable when there is error:
DataGridRow gridRow = dgInventory.ItemContainerGenerator.ContainerFromIndex(row) as DataGridRow;
if (gridRow != null)
{
DataGridCell cell = dgInventory.Columns[column].GetCellContent(gridRow).Parent as DataGridCell;
cell.BorderBrush = Brushes.Red;
cell.IsEditing = true;
cell.ToolTip = tooltip;
}
Once the grid loads in the page, I can now edit the cells with error. However, when I access the ItemsSource for the DataGrid, it still shows the same old data. The DataGrid code in XAML is this:
<DataGrid Name="dgInventory" ScrollViewer.CanContentScroll="False" IsManipulationEnabled="True" CellEditEnding="dgInventory_CellEditEnding" IsReadOnly="True" />
Can you please provide me a way to edit the cells in the DataGrid. Thanking you in advance.
DataGridColumnXAML as well - it will help to see how the columns are being databound, and what type of columns they are. Also, does your CellEditEnding ever get fired? - Brian S