tk.
tk.

Reputation: 1216

Cell color of WPF DataGrid back to the default

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.

Upvotes: 2

Views: 3610

Answers (1)

Kent Boogaart
Kent Boogaart

Reputation: 178680

dgc.ClearValue(DataGridCell.BackgroundProperty);

Upvotes: 5

Related Questions