我将公共字典定义为
public Dictionary<string, double> comboBoxSelections { get; set; }
并使用
向其中添加项目this.comboBoxSelections = new Dictionary<string, double>();
comboBoxSelections.Add(currItem, d);
我想将它用作WPF中ComboBox的ItemsSource,因此每当更新comboBoxSelections时,我都会在ComboBox中看到可供选择的更新项目。所以我想也许我需要将它包装在一个ObservableCollection中作为
public ObservableCollection<Dictionary<string, double>> comboBoxSelections { get; set; }
this.comboBoxSelections = new ObservableCollection<Dictionary<string, double>>();
将新词典项添加到ObservableCollection的语法是什么?有点像...
comboBoxSelections.Add(new Dictionary<string, double>(currItem, d));