<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Orientation="Horizontal">
  <StackPanel.Resources>
    <Style x:Key="AlternatingRowStyle" TargetType="{x:Type Control}">
      <Setter Property="Background" Value="Green"/>
      <Setter Property="Foreground" Value="White"/>
      <Style.Triggers>
        <Trigger Property="ItemsControl.AlternationIndex" Value="1">
          <Setter Property="Background" Value="White"/>
          <Setter Property="Foreground" Value="Black"/>
        </Trigger>
      </Style.Triggers>
    </Style>
  </StackPanel.Resources>
  <ListBox AlternationCount="2" Margin="10" Width="200"
    ItemContainerStyle="{StaticResource AlternatingRowStyle}">
    <ListBoxItem>Element 1</ListBoxItem>
    <ListBoxItem>Element 2</ListBoxItem>
    <ListBoxItem>Element 3</ListBoxItem>
    <ListBoxItem>Element 4</ListBoxItem>
    <ListBoxItem>Element 5</ListBoxItem>
  </ListBox>
  <TreeView AlternationCount="2" Margin="10" Width="200"
    ItemContainerStyle="{StaticResource AlternatingRowStyle}">
    <TreeViewItem Header="Korzeń 1" AlternationCount="2"
      ItemContainerStyle="{StaticResource AlternatingRowStyle}">
      <TreeViewItem Header="Podelement 1"/>
      <TreeViewItem Header="Podelement 2"/>
      <TreeViewItem Header="Podelement 3"/>
    </TreeViewItem>
    <TreeViewItem Header="Korzeń 2" AlternationCount="2"
      ItemContainerStyle="{StaticResource AlternatingRowStyle}">
      <TreeViewItem Header="Podelement 1"/>
      <TreeViewItem Header="Podelement 2"/>
      <TreeViewItem Header="Podelement 3"/>
    </TreeViewItem>
  </TreeView>
</StackPanel>
