У меня есть список в следующем виде:
<ListView x:Name="lvLedger"
Height="{Binding Path=GridHight, ElementName=ledgerList}"
Width="{Binding Path=GridWidth, ElementName=ledgerList}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemsSource="{Binding}"
BorderThickness="0"
Background="Transparent"
BorderBrush="Transparent"
DataContextChanged="lvLedger_DataContextChanged">
<ListView.View>
<GridView>
<GridViewColumn x:Name="c2ServiceDate" Header="Service Date" Width="82" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=servicedate}"
ToolTipService.ShowDuration="60000"
ToolTipService.InitialShowDelay="0"
ToolTip="{Binding Path=type}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn x:Name="c3CPT" Header="Code" Width="50">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=cpt}"
ToolTipService.ShowDuration="60000"
ToolTipService.InitialShowDelay="0"
ToolTip="{Binding Path=type}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
<!--More columns here--> </GridViewColumn></GridView></ListView.View></ListView>
То, что я хотел бы сделать, это изменить цвет фона строки на основе комбинации даты обслуживания и кода. Таким образом, у меня может быть 3 строки подряд с одинаковой датой обслуживания и кодом, которые должны иметь один и тот же фон, за которыми следуют 2 строки другого цвета, а затем чередоваться в соответствии с тем же правилом
1/19/11 356 (синий)
1/19/11 356 (синий)
1/19/11 235 (красный)
20.02.11 356 (синий)
20.02.11 356 (синий)
20.02.11 356 (синий)
21.02.11 564 (красный)
21.02.11 564 (красный)
21.02.11 564 (красный)
21.02.11 564 (красный)
25.02.11 798 (синий)
и так на ...
ItemSource привязан к DataView из внешнего элемента управления.
Я действительно понятия не имею, как я могу сделать что-то подобное, и любая помощь будет оценена.