5

このコードを使用してBackground、WPF 内のセルを含むいくつかのエラー データを変更しようとしています。DataGrid

DataGridRow gridRow = dgInventory.ItemContainerGenerator.ContainerFromIndex(0) as DataGridRow;
DataGridCell cell = dgInventory.Columns[1].GetCellContent(gridRow).Parent as DataGridCell;

cell.Background = Brushes.Gray;

gridRow.IsSelected = true;
gridRow.Focus();

ただし、これを行うと、同じ列のセルで上記の背景色の変更が発生し、14 (約) 行ごとに定期的にDataGrid. Background1 つの行のを変更することのみを目的としています。誰かがこの問題の修正を提供できますか? 前もって感謝します。

4

1 に答える 1