wpf: DataGrid disable selected row styles - or row selecting
figured out the XAML to get rid of selection style.. not ideal, but close enough..
<Style x:Key="CellStyle" TargetType="{x:Type DataGridCell}"> <Setter Property="Foreground" Value="Black" /> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="{x:Null}" /> <Setter Property="BorderBrush" Value="{x:Null}" /> </Trigger> </Style.Triggers></Style>
Here's what worked for me:
<DataGrid> <DataGrid.CellStyle> <Style TargetType="{x:Type DataGridCell}"> <Style.Triggers> <Trigger Property="DataGridCell.IsSelected" Value="True"> <Setter Property="BorderBrush"> <Setter.Value> <SolidColorBrush Color="Transparent"/> </Setter.Value> </Setter> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="Transparent"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </DataGrid.CellStyle> <!-- ... --></DataGrid>
I found another way that works well for my situation. I set this style for all cells because I don't want the user to select any cells.
<Style TargetType="{x:Type DataGridCell}"> <Setter Property="IsHitTestVisible" Value="False"/></Style>