Possible Duplicate:
Binding SelectedItems of Listview
I have a ListView and User can select multiple items. I need to get list of items selected from ListView in my View Model.
please suggest to get SelectedItems from ListView.
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are two ways I usually do this
If I only need to know what is selected for the purpose of a command, I will setup my
RelayCommandorDelegateCommandin theViewModelto expect a parameter of typeIList<SomeClass>and pass theListView.SelectedItemsin as theCommandParameterThe other method I often use is to create an
IsSelectedproperty on whatever data item is being used in theListView, and bind it to theListViewItem.IsSelectedpropertyThen my
ViewModelcan find out if an item is selected or not by looking at it’sIsSelectedproperty