私のバインディングは次のように設定されています:
_selectXAxisUnitViewModelBindingSource = new BindingSource();
_selectXAxisUnitViewModelBindingSource.DataSource = typeof(SelectXAxisUnitViewModel);
_selectedUnitComboBoxBindingSource = new BindingSource();
_selectedUnitComboBoxBindingSource.DataSource = _selectXAxisUnitViewModelBindingSource;
_selectedUnitComboBoxBindingSource.DataMember = "AvailableUnits";
_selectedUnitComboBox.ComboBox.DataSource = _selectedUnitComboBoxBindingSource;
_selectedUnitComboBox.ComboBox.DisplayMember = String.Empty;
_selectedUnitComboBox.ComboBox.ValueMember = String.Empty;
_selectedUnitComboBox.ComboBox.DataBindings.Add("SelectedItem",
_selectXAxisUnitViewModelBindingSource,
"SelectedUnit", true, DataSourceUpdateMode.OnPropertyChanged);
// this is a bug in the .Net framework: http://connect.microsoft.com/VisualStudio/feedback/details/473777/toolstripcombobox-nested-on-toolstripdropdownbutton-not-getting-bindingcontext
_selectedUnitComboBox.ComboBox.BindingContext = this.BindingContext;
プロパティ「AvailableUnits」は文字列のコレクションであり、「SelectedUnit」は文字列プロパティです。これでドロップダウンリストが期待どおりに表示されますが、リスト内の項目を選択すると、変更がバインディングソースに伝達されません。私が間違っていることについて何か考えはありますか?
アップデート:
小さなテストプロジェクトを作成しましたが、ToolStripComboBoxを別のToolStripItemのサブアイテムとして追加すると、この問題が発生します。ToolStripItemをMenuStripに直接追加すると、すべてが正常に機能します。サブアイテムとして追加された場合、BindingContextはToolStripComboBoxに割り当てられず(コードコメントを参照)、これを機能させるために必要な処理が修正されていないようです。