2011年8月23日

Blend ListBox結構

Alternate Row Color in ListBox in WPF


<Window.Resources>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#19f39611">Setter>
Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#19000000">Setter>
Trigger>
Style.Triggers>
Style>
Window.Resources>

<ListBox x:Name="lbPersonList" Margin="19,17,162,25" AlternationCount="2">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
DataTemplate>
ListBox.ItemTemplate>
ListBox

沒有留言: