In order to change foreground color of ListBoxItem base on condition, I can do inside DataTemplate.Triggers:
<ListBox.ItemTemplate>
<DataTemplate>
...
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Name}" Value="Item1">
<Setter Property="ListBoxItem.Foreground" Value="Blue" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
Or inside ItemContainerStyle:
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding Name}" Value="Item1">
<Setter Property="Foreground" Value="Blue" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
I wonder what's the difference between DataTemplate.Triggers and Style.Triggers? Which one happen first? Most importantly, what's the semantic meaning of each trigger group?