1
votes

I have a combobox and set the itemssource to a list of strings:

private List<string> list = new List<string>();
...
ComboBox cbo = new ComboBox();
cbo.ItemsSource = list;

The combobox gets filled successful on startup.
But when the list is changed, the combobox doesn't update its items, BUT only when I expanded the items before, else the combobox gets updated...
Also weird: when I trace the count of items of the combobox, the count is the correct updated number, but the displayed items aren't.
Somebody has an idea, what's going on here?

EDIT: See solution in comments to post of Robert

3
You should post more of your code. The problem in the code you posted is solved by using ObservableCollection, but you should add here at least the code that updates your list.coldandtired

3 Answers

3
votes

I guess you need to use ObservableCollection instead of List, because ComboBox needs to be notified whenever the collecion changes.

1
votes

Change List into ObservableCollection.

0
votes

Use ObservalbeCollection. It has inbuilt mechanism to notify and change in the number of items.