Reputation:
I have a DataGrid with four columns that will have a control in each column for each row. Whenever I select one of the controls in a column whichever row it belongs to gets highlighted white. The background will be white so the controls still show. I don't want the row to highlight at all.
<DataGrid>
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Upvotes: 0
Views: 939
Reputation: 81313
You need to override HighlightBrushKey
for your DataGrid but in case you set that to white, highlighted text also corresponds to white color so that won't be visible.
So, basically you need to override HighlightBrushKey
to White
and HighlightTextBrushKey
to Black
to make it work. This is how you override it -
<DataGrid>
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="White"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}"
Color="Black"/>
</DataGrid.Resources>
</DataGrid>
Upvotes: 1
Reputation: 12315
Try this
<DataGrid SelectionMode="Single" SelectionUnit="Cell"
Upvotes: 0