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

CheckComboBox Binding Data

Developer
Jan 21, 2014 at 6:18 PM
Please post a code snippet on how to bind data to this checkedcomb box. I find it difficult to understand how to pass two data valus, one containing the total Items and the other containing selected items of these.

I tried the following and it worked but I just want to bind a single data source.
  1. I set
    cmbBox.Itemsource=listOfItems;
  2. I added the items to be selected to the SelectedItems property using a foreach loop. And these items are also added in the
    foreach(string str in LstSelectedItems)
    cmbBox.SelectedItems.Add(str);
But there should be a better option right??
Developer
Jan 21, 2014 at 6:28 PM
Hi,

Here's a solution :
List<string> listOfItems = new List<string>() { "abc", "def", "ghi", "jkl" };
List<string> selectedItems = new List<string>() { listOfItems[0], listOfItems[2] };
_checkComboBox.ItemsSource = listOfItems;
 _checkComboBox.SelectedItemsOverride = selectedItems;