Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 列表框的着色_Wpf_Xaml_Listbox - Fatal编程技术网

Wpf 列表框的着色

Wpf 列表框的着色,wpf,xaml,listbox,Wpf,Xaml,Listbox,是否可以在WPF列表框中对该行进行着色 白色的 浅灰色 灰色 白色 浅灰色 等等 谢谢是的,这是可能的。您可以使用ListBox的AlternationCount属性。差不多 <Style TargetType="{x:Type ListBoxItem}"> <Style.Triggers> <Trigger Property="ItemsControl.AlternationIndex" Value="0">

是否可以在WPF列表框中对该行进行着色

白色的 浅灰色 灰色 白色 浅灰色 等等


谢谢

是的,这是可能的。您可以使用ListBox的AlternationCount属性。差不多

<Style TargetType="{x:Type ListBoxItem}">
    <Style.Triggers>
        <Trigger Property="ItemsControl.AlternationIndex" Value="0">
            <Setter Property="Background" Value="White"></Setter>
        </Trigger>
        <Trigger Property="ItemsControl.AlternationIndex" Value="1">
            <Setter Property="Background" Value="LightGray"></Setter>
        </Trigger>
        <Trigger Property="ItemsControl.AlternationIndex" Value="2">
            <Setter Property="Background" Value="Gray"></Setter>
        </Trigger>
    </Style.Triggers>
</Style>
然后在列表框上设置AlternationCount

<ListBox AlternationCount="3"
         ...>

是的,这是可能的。您可以使用ListBox的AlternationCount属性。差不多

<Style TargetType="{x:Type ListBoxItem}">
    <Style.Triggers>
        <Trigger Property="ItemsControl.AlternationIndex" Value="0">
            <Setter Property="Background" Value="White"></Setter>
        </Trigger>
        <Trigger Property="ItemsControl.AlternationIndex" Value="1">
            <Setter Property="Background" Value="LightGray"></Setter>
        </Trigger>
        <Trigger Property="ItemsControl.AlternationIndex" Value="2">
            <Setter Property="Background" Value="Gray"></Setter>
        </Trigger>
    </Style.Triggers>
</Style>
然后在列表框上设置AlternationCount

<ListBox AlternationCount="3"
         ...>

谢谢,成功了。但是我有两个相同形式的列表框,两个都有这个,两个列表框都有这个颜色。这个样式是针对ListBoxItem的,所以它将适用于所有列表框。谢谢,这就成功了。但是我有两个相同形式的列表框,两个都有这个,两个列表框都有这个颜色。这个样式是针对ListBoxItem的,所以它将适用于所有的列表框。