I have a "playlist" and I want to emphasize "now playing" item.
I tried this
<!-- Row 5: Playlist -->
<ListBox x:Name="Tracks" MinHeight="400" Grid.Row="5" Margin="20">
<ListBox.ItemTemplate>
<DataTemplate>
<DockPanel Height="44" Width="436" Dock="Left">
<StackPanel Orientation="Vertical" Width="374" Name="Wrapper">
<Label Content="{Binding Path=title}" Name="Test" Foreground="CornflowerBlue" FontSize="14" Padding="0" />
<Label Content="{Binding Path=artist}" Foreground="DarkGray" FontSize="14" Padding="0" />
</StackPanel>
<Label Content="{Binding Path=DurationFormatted}" Foreground="DarkGray" Width="62" Padding="0" DockPanel.Dock="Right" HorizontalContentAlignment="Right" />
</DockPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=NowPlaying}" Value="True">
<Setter TargetName="Wrapper" Property="Background" Value="LightBlue"/>
<Setter TargetName="Test" Property="FontSize" Value="24"/>
<Setter Property="ListBoxItem.Foreground" Value="Red" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
And this
<ListBox.ItemTemplate>
same stuff without Triggers section
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=NowPlaying}" Value="True">
<Setter Property="ListBoxItem.Background" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
NowPlaying is just a bool property of audio model and I checked in debugger that current object indeed get NowPlaying == true. But both of this triggers does not change item look. What I'm doing wrong? Also, as for me, I prefer imperative style. Is it easy enough to do this from codebehind?
P.S. I set extreme values for emphasized item just for testing :)