views:

15

answers:

1

I'm using buildin WPF DataGrid in .net 4.

I can set the background of a DataGridCell programatically like below.

DataGridCell dgc = this.GetCell(i, j);  //GetCell is extension func
dgc.Background = Brushes.LightGray;

My question is, how can i remove the background color i set and back to the default? By "default" I mean the default transparent background with the blueish color when the cell is selected. If i just set back the background of the cell like below,

dgc.Background = Brushes.Transparent;

then, it does not become blueish when it is selected.

A: 
dgc.ClearValue(DataGridCell.BackgroundProperty);

HTH,
Kent

Kent Boogaart
exactly what i wanted. thnx.
tk
It seems SO does not allow me to accept an answer in 10 mins.
tk