I have a Listbox with an Alternation Index of 2 on it. I then have a style set up to provide styling on the different alternation indexes.
<Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid>
<Border x:Name="Bd" SnapsToDevicePixels="true">
<ContentPresenter Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<Rectangle x:Name="HoverRectangle"
Height="Auto"
SnapsToDevicePixels="True"
Stroke="{StaticResource Gold}"
StrokeDashCap="Square"
StrokeThickness="0" />
<Rectangle x:Name="KeyboardFocusRectangle"
Height="Auto"
SnapsToDevicePixels="True"
Stroke="{StaticResource BrightBlue}"
StrokeDashCap="Square"
StrokeThickness="0" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter TargetName="Bd" Property="Background" Value="{StaticResource LightGray}" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter TargetName="Bd" Property="Background" Value="{StaticResource VeryLightGray}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I also want to change the background on the items if they happen in the future. I have a function IsFuture returning a boolean. I then got this code working in the data template to style the background.
<DataTemplate x:Key="MeetingListItemTemplate">
<Grid x:Name="grid">
<!-- Removed lots of stuff here-->
</Grid>
<DataTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=IsFuture}" Value="True"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Background" Value="#0094d6" TargetName="grid"/>
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
I set up the MutliDataTrigger so I could have the condition for alternation index and then I would use a different blue for each alternation but I'm not sure how I can get alternation index from here. Any ideas?