I have a WPF DataGrid that is based on a style with the trigger:
<Style TargetType="DataGridCell" x:Key="DataGridCellStyle">
<Style.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Background" Value="Blue" />
<Setter Property="BorderBrush" Value="Blue" />
</Trigger>
</Style.Triggers>
</Style>
A short description of the problem: In one case, after changing the selection, the previews not selected row is still marked with Blue and appear as it is selected.
And more detailed: When I'm selecting row X , row X is colored with blue. When I'm selecting a different row the color in row X changes back to default as it should.
Except for one case: 1. I'm standing on row X and it is selected. 2. I'm swapping it's place with row Y (from code) . 3. Row X is now still selected after the swap. 4. I'm going to a different row , The new row is selected , row X is not selected anymore but it's background is still Blue.
I'm not sure it can add any extra information, but I'm adding the relevant part of the code of the swapping: *_commands is binded to the ItemsSource of the dataGrid
Command tmp = _commands[indx1];
_commands[indx1] = _commands[indx2];
_commands[indx2] = tmp;
Commands[indx + 1].IsSelected = true;
Commands[indx].IsSelected = false;
private ObservableCollection<CustomCommand> _commands = new ObservableCollection<CustomCommand>();
public ObservableCollection<CustomCommand> Commands
{
get
{
return _commands;
}
set
{
_commands = value;
NotifyPropertyChanged("Commands");
}
}
One more thing - This happens only in some of the computers and in others it behaves as expected and the color is set back to default.
Thanks, Dana.