Hi.
I have a problem with the way a ListView selects its items.
I have a ListView bound to an ObservableCollection of items which have a 'Selected' property. I have bound the selection state like this:
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="IsSelected" Value="{Binding Path=Selected, Mode=TwoWay}" />
</Style>
</ListView.ItemContainerStyle>
But with approxemitly 1000 Items in the list, the ListView only holds containers for the visible objects on start or about 500 when already scrolled through. So even if i select all (Ctrl+A), the selection gets only set for these 500.
I also tried a lot of other solutions that came to my mind, but none worked.
- ListView.SelectedItems cant be bound to.
- Using SelectionChanged event to set 'Selected' property - Fired a lot of SelectionChanged events when scrolling to an area, that was not cached at selection time and therefore the items were 'new selected' for the list.
- Using SelectionChanged event of the ListView to add and remove the changed selection to an extra collection - Could not select from ViewModel, since works only in one direction.
Is it anyhow possible to have a ListView where I can select more than 500 Items and have this info somewhere in the ViewModel. It should also be possible to select/deselect from ViewModel.
Thanks