Binding SelectedItems of Listview

不打扰是莪最后的温柔 提交于 2019-12-17 21:18:13

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/8999509/binding-selecteditems-of-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!