Search code examples
c#wpflistviewcollectionview

Binding SelectedItems of Listview


how can i bind SelectedItems of a ListView? My ListView has multipleSelection attribute and I'm using CollectionView for its contents..

I've heard about Attached property and I tried implementing this with the one I found here: Sync SelectedItems in a muliselect listbox with a collection in ViewModel

I can multiple select the items by clicking rows but I can't use the Shift keyboard for multi-selecting many rows instantly... Also, when I filter my collection and refresh it, my selection are all deselected after the refresh..

How can I make it so that whenever my CollectionView refreshes, the previously selecteditems are still selected after the refresh...?

Can someone also help me how to manipulate logically the selected items through my viewmodel?


Solution

  • May be you should add the IsSelected property to the ListViewItem's view model.