0

私はDataGrid、WPF でセルを検証するアプリケーションに取り組んでいます。たとえば、セルにエラーがある場合、そのセルを編集可能にしています。ただし、変更されたデータはデータ グリッドの にバインドされていませんItemsSource。以下は、エラーが発生したときにセルを編集可能にするために使用しているコードです。

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;
}

グリッドがページに読み込まれると、セルをエラーで編集できるようになります。ただし、 の にアクセスするItemsSourceDataGrid、同じ古いデータが表示されます。XAMLのDataGridコードは次のとおりです。

<DataGrid Name="dgInventory" ScrollViewer.CanContentScroll="False" IsManipulationEnabled="True" CellEditEnding="dgInventory_CellEditEnding" IsReadOnly="True" />

のセルを編集する方法を教えてくださいDataGrid。よろしくお願いします。

4

1 に答える 1