I have a listview that you select a row/item on. This is linked to a datatrigger that displays an image on the row. The image should only be displayed when the row is selected.
This part works fine, however when you move the focus to something else, such as a textbox, or a messagebox is displayed, the listviewitem loses focus ie the highlight on the row is no longer displayed. The problem is that my image still remains. It should be hidden/collapsed when the listview loses focus... It works fine if you select a different item/row on the listview.
Can anyone help on this please?
<Style x:Key="deleteImageStyle" TargetType="{x:Type Image}">
<Setter Property="Source" Value="Resources/iconDelete.png" />
<Setter Property="Margin" Value="0,2,5,0" />
<Setter Property="Height" Value="16" />
<Setter Property="Width" Value="16" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Cursor" Value="Hand" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="False">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Visibility" Value="Hidden" />
</Trigger>
</Style.Triggers>
</Style>
Regards
TravisPUK