I have a WPF DataGrid where the SelectedItem is bound to the ViewModel property.
SelectedItem="{Binding DataContext.SelectedBooking, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
If the user clicks on a line, selecting it, the only visual key is that the gray background of the line becomes a little lighter. I need to make this more obvious, so I tried to add them separately:
<DataGrid.RowStyle> <Style TargetType="{x:Type DataGridRow}"> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Foreground" Value="Red"/> <Setter Property="Background" Value="Red" /> </Trigger> </Style.Triggers> </Style> </DataGrid.RowStyle>
and
<DataGrid.Resources> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Red"/> </DataGrid.Resources>
The result is the same. When a user makes a single click on a line, it flashes red very briefly, and then returns to pale gray, although the line really remains selected. If they click on it a second time, it will turn red and remain red.
If I unlink the selected item, it works as expected. How can I do this work regardless of binding?
source share