I’ve a listview like this
ListView:
—————–
- Mango
- Orange
- Grapes
- Grapes
- Grapes
- Apple
- Strawberry
Whenever i navigate using downarrow, the BlueHighlight pauses at the first Grapes, a dotted rectangle start from second grapes and pauses at the third grapes, then the BlueHighlight resumes from Apple. This seems weird and it grows more weird when the navigation is upwards. It jumps from Apple to Orange or mango.
Is this due to Virtualization?
It seems only the duplicate data (grapes) is creating the problem. Any Help?
The dotted rectangle is your keyboard focus. The blue rectangle is your selection.
As you move down your keyboard focus tracks where you are. The selection, however, tracks which item is selected. When the same item is in the list several times, the selection rectangle can only be shown on one of them.
To make this work the way you are expecting, wrap your items inside your ObservableCollection. So instead of:
you would write
In your
ListBoxyourItemTemplatecan include a singleContentPresenterthat presents the fruit inside the wrapper (eg.<ContentPresenter Content="{Binding Fruit}" />).