Based on some offline support from Jenny (see below), I have now created a working project that allows me to sort, group and filter the grid without the cell colours becoming randomised. It was simply a matter of returning DependencyProperty.UnsetValue from the converter instead of cell.Background.
I have attached the example project. However, I am still having one more problem with it. If I change the view to TableflowView, an error occurs in the converter. The DataCell.DataContext is no longer a DataRowView, it is an EmptyDataItem.
How do I resolve this?
Thanks,
Jason
PS: The solution Jenny provided where highlighting is based on visual row versus the source wasn't required for my project, so I haven't implemented this part of the solution, only the return value of the converter.
Offline support from Jenny:
It's a bit tricky in the converter to return the Cell.Background of something you are in fact using the converter for.
The correct way to tell it to revert to its default value in a converter is to return DependencyProperty.UnsetValue;
So, if you replace "return cell.Background;" with "return DependencyProperty.UnsetValue;" things should start to work better.
Second, you use row.Table.Rows.IndexOf(row) in your converter, which will give you the position based on the original order of the table. Meaning that your highlight will not be based on the previous visual row. If you want to get the index of the row vs the source (the DataGridCollectionView), you can use "(xcdg:DataGridVirtualizingPanel.ItemIndex)".
Here is an example with your code :
<Style TargetType="{x:Type xcdg:DataCell}">
<Setter Property="Background">
<Setter.Value>
<MultiBinding Converter="{StaticResource highlightSeriesChangeConverter}">
<Binding Mode="OneWay" RelativeSource="{RelativeSource Self}" />
<Binding Mode="OneWay" RelativeSource="{RelativeSource Self}" Path="Content" />
<Binding Mode="OneWay" RelativeSource="{RelativeSource Self}" Path="DataContext" />
<Binding Mode="OneWay" RelativeSource="{RelativeSource Self}" Path="ParentRow.(xcdg:DataGridVirtualizingPanel.ItemIndex)" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
And after, just use that new info into your converter.
Associate, .NET Development
Morgan Stanley, UK