0
votes

I have a listbox and who's itemsource is bound to a List with SelectionMode="Single". My listbox also has an ItemContainerStyle set for it as below:

<ListView.ItemContainerStyle>
    <Style TargetType="{x:Type ListViewItem}">
        <Style.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
            <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
        </Style.Resources>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Blue" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ListView.ItemContainerStyle> 

When I remove an item from the list, I'm not able to reselect the item unless I select a different item and then go back to it. Can anyone give input on this?

1

1 Answers

0
votes

Depending on how you are removing items from the list, the ListView might lose focus after the removal, which can affect the Highlight Color of the SelectedItem. The item is actually Selected but does not appear to be to the user because the ListView is not the active control. For example, this could happen if you click a button elsewhere on your form to delete an item from the ListView.

Try calling Focus() on your ListView instance after the remove operation.