This project has moved. For the latest updates, please go here.

Obtain selected values from a CheckComboBox

Aug 8, 2012 at 10:53 AM

Hi,

 

How am I supposed to get the selected values from a CheckComboBox? I understand that SelectedValues returns a string of indexes of the selected values, but how can I access those values from the ViewModel?

Do I need to fire an event when any SelectedItem changes and manage it myself?

 

Thanks!

Aug 8, 2012 at 12:50 PM

I'm getting closer to it, but I have a problem:  

CheckComboBox SelectedValue doesn't return the indexes of the Items but the value of the items instead.

 

How do you solve it?

Developer
Aug 8, 2012 at 3:48 PM

You're right, CheckComboBox SelectedValue doesn't return the indexes of the Items but the value of the items instead. Documentation needs to be updated.

To get the SelectedValues from a CheckComboBox, try with CheckComboBox.SelectedItems.

If you are looking for indexes, try to do the same as in the "Color" example of the Extended WPF Toolkit. In Resume :

Many Person are created with a Level property set ( a different int for each of them.)

In XAML, The CheckComboBox.ValueMemberPath = Level.

When CheckComboBox.SelectedValue is set to the string "1,2,3", the CheckComboBox will try to find all the Person with the ValueMemberPath equals to each of the CheckComboBox.SelectedValue. They will then be added to the CheckBox.SelectedItems collection.

Aug 9, 2012 at 10:56 AM

Thanks,

In fact, I prefer "values" than indexes, but the problem is that I wasn't completely sure what a "value" was. Finally, I managed to do what I wanted with SelectedValue, using ValueMemberPath to choose which property of my Class I wanted to be the "value".

I guess an example added to the documentation would be great for newbies like me ;)

Mar 25, 2014 at 6:11 AM
string str = CheckComboBox.SelectedValue;
It will return selected values in comma(,) separated format.