Hi,
I have a DataGrid and I apply a style to the selector row
which is defined below. This sets the border colour depending on the status of
the data in the row.
<Style x:Key="rowSelectorStyle" TargetType="{x:Type xcdg:RowSelector}">
<Style.Setters>
<EventSetter Event="MouseEnter" Handler="OnRowSelectorMouseEnter"/>
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="OnRowSelectorPreviewMouseLeftButtonDown"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Margin" Value="1"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="BorderBrush"
>
<Setter.Value>
<MultiBinding Converter="{StaticResource
fieldStatusToBrushConverter}">
<Binding Mode="OneWay" RelativeSource="{RelativeSource Self}" />
<Binding Mode="OneWay" RelativeSource="{RelativeSource Self}" Path="DataContext"
/>
</MultiBinding>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
This works fine until I sort the rows using the built in
sort by clicking on a column. The causes the rows to be re-ordered but the
style for each row does not seem to update to match the new position of the
data.
If I force row recycling by scrolling the grid then it seems
the style gets applied correctly i.e. the row selector border is applied to the
correct rows.
Is it possible to ensure the style gets refreshed when
sorting rows? I have tried reapplying the style for each row on
ItemsSourceChangeCompleted event but this does not resolve the issue.
Many Thanks
Pete