交互インデックスが2のリストボックスがあります。次に、さまざまな交互インデックスにスタイリングを提供するようにスタイルを設定します。
<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>
また、将来発生した場合は、アイテムの背景を変更したいと思います。ブール値を返す関数IsFutureがあります。次に、このコードをデータテンプレートで機能させて、背景のスタイルを設定しました。
<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>
MutliDataTriggerを設定して、代替インデックスの条件を設定し、代替ごとに異なる青を使用しましたが、ここから代替インデックスを取得する方法がわかりません。何か案は?