Is it possible to get this row coloring in the WPF Listbox?
White
LightGray
Gray
White
LightGray
etc.?
Thanks
Is it possible to get this row coloring in the WPF Listbox?
White
LightGray
Gray
White
LightGray
etc.?
Thanks
Hi,
Yes it's possible. You can use the AlternationCount Property of the ListBox. Something like
<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>
And then just set the AlternationCount on your ListBox
<ListBox AlternationCount="3"
...>