Is it possible to change ListBoxItem style up to its DataContext property "IsFail" (true, false).
ListBoxItem style is defined via VisualStateManager States in ItemContainerStyle
.
<ListBox x:Name="ShortInfoListBox" Background="{x:Null}"
ItemTemplate="{StaticResource ShortInfoTemplate}"
ItemContainerStyle="{StaticResource ListBoxItemContainerStyle}"
ItemsSource="{Binding HistoryInfo, Mode=OneWay}"
Style="{StaticResource ListBoxStyle}"
SelectedItem="{Binding CurrentInfo, UpdateSourceTrigger=Explicit, Mode=TwoWay}"
SelectionChanged="ShortInfoListSelectionChanged" ScrollViewer.HorizontalScrollBarVisibility="Disabled"/>
ItemContainerStyle
defines visual states:
<VisualStateGroup x:Name="FailState">
<VisualState x:Name="FailFocused">
<Storyboard>
<ColorAnimation Duration="0" To="#FFFF5200" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="BackgroundRect" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
<VisualState x:Name="FailUnfocused">
<Storyboard>
<ColorAnimation Duration="0" To="#FFB86B47" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="BackgroundRect" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
I would like to apply FailState to the ListBoxItem if IsFail property = true