I'm trying to set the cell color of a WPF datagrid. But I can't get this to work.
Code:
Dim firstRow As DataGridRow = TryCast(DG1.ItemContainerGenerator.ContainerFromItem(DG1.Items(0)), DataGridRow)
Dim firstColumnInFirstRow As DataGridCell = TryCast(DG1.Columns(0).GetCellContent(firstRow).Parent, DataGridCell)
'set background
firstColumnInFirstRow.Background = Brushes.Red