WPF ItemsControl.AlternationIndex 在触发器中不起作用

WPF ItemsControl.AlternationIndex doesn't work in a Trigger

我读了很多关于这个的东西,但我找不到解决我的问题的方法。 我为 ListViewItem 定义了一个新样式,但是 ItemsControl.AlternationIndex 的 属性 没有触发。

<Style TargetType="ListViewItem">
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Background" Value="{DynamicResource StandardBackgroundColor}" />
    <Setter Property="Foreground" Value="{StaticResource StandardForegroundColor}" />
    <Style.Triggers>
        <Trigger Property="ItemsControl.AlternationIndex" Value="0">
            <Setter Property="Background" Value="#181818" />
        </Trigger>
        <Trigger Property="ItemsControl.AlternationIndex" Value="1">
            <Setter Property="Background" Value="#626262" />
        </Trigger>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Background" Value="{StaticResource DisabledGray}" />
        </Trigger>
    </Style.Triggers>
</Style>
<Style x:Key="IOListViewItem" TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource {x:Type ListViewItem}}">
    <Setter Property="Height" Value="60" />
    <Setter Property="FontSize" Value="18" />
    <Setter Property="FontWeight" Value="Bold" />
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="True"></Setter>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ListViewItem}">
                <Border Name="Border" Padding="2" SnapsToDevicePixels="true">
                    <ContentPresenter 
                              Focusable="True"
                              Visibility="Visible"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"
                              RecognizesAccessKey="True"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="ItemsControl.AlternationIndex" Value="0">
                        <Setter Property="Background" Value="Red" />
                    </Trigger>
                    <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                        <Setter Property="Background" Value="#626262" />
                    </Trigger>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="{StaticResource DisabledGray}" />
                    </Trigger>
                    <Trigger Property="IsSelected" Value="true">
                        <Setter TargetName="Border" Property="Background" Value="{StaticResource Blue}"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

非常感谢!

ListView 设置 AlternationCount="2" 以查看备用项目的不同颜色

IOListViewItem 样式中的 ControlTemplate 也不使用背景

<Border Name="Border" Padding="2" 
        Background="{TemplateBinding Background}" 
        SnapsToDevicePixels="true">