I have a simple WPF form with a ComboBox and a button. The ComboBox's ItemSource is a Dictionary which includes names of files in a directory. The button is for adding new files by copying them using Open File Dialog.
Code i used for binding:
cmbClasses.ItemsSource = classList;
cmbClasses.DisplayMemberPath = "Key";
cmbClasses.SelectedValuePath = "Value";
I want the ComboBox to refresh items after adding new file to Dictionary and set is as SelectedItem. I tried this for refreshing but it didn't work:
cmbClasses.Items.Clear();
cmbClasses.ItemsSource = classList;
cmbClasses.DisplayMemberPath = "Key";
cmbClasses.SelectedValuePath = "Value";
I saw a few questions here but none of them helped. Anyone know how can i do that?