wpf datagrid alternate row coloring
问题 I have tried this method.. without luck.. <Style TargetType="{x:Type DataGridRow}"> <Style.Triggers> <Trigger Property="ItemsControl.AlternationIndex" Value="0"> <Setter Property="Foreground" Value="Red" /> </Trigger> </Style.Triggers> </Style> Is there a way to get the row Index? I have even tried <DataTrigger Binding="{Binding AlternationIndex}" Value="0"> <Setter Property="Foreground" Value="Green"></Setter> </DataTrigger> 回答1: Unless already done, you have to set the AlternationCount