Binding SelectedItems of Listview
-
14-11-2019 - |
Question
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.
OTHER TIPS
You will have to use your own code to keep the selected items after a refresh. Maybe make a copy of your collection before the refresh and afterwards a simple for to check all the checked items in your current collection.
Change your selectection mode to extended for your listbox for the shift key to work.
As for manipulating logically the selected items, you will have to give a lot more info on what exactly you want done.