我将我的silverlight组合框绑定到视图模型。不幸的是,在我选择组合框中的项目后,下拉菜单关闭后组合框中没有显示所选项目。
我的Viewmodel具有DocumentTypes(对于数据源,它具有DocumentTypeName,DocumentTypeID的属性)和SelectedDocumentTypeID(用于保存所选项目)的属性,我正在使用它。
这是我绑定组合框的代码,我在代码隐藏中执行:
var dgViewModel = new DataGridViewModel();
Binding bDocTypes = new Binding() { Source = dgViewModel, Path = new PropertyPath("DocumentTypes"), Mode = BindingMode.OneWay };
Binding bDocTypeSelectedValue = new Binding() { Source = dgViewModel, Path = new PropertyPath("SelectedDocumentTypeID"), Mode = BindingMode.TwoWay };
this.DataContext = dgViewModel;
comDokumententyp.SetBinding(ComboBox.ItemsSourceProperty, bDocTypes);
comDokumententyp.SetBinding(ComboBox.SelectedValueProperty, bDocTypeSelectedValue);
comDokumententyp.DisplayMemberPath = "DocumentTypeName";
comDokumententyp.SelectedValuePath = "DocumentTypeID";
我错过了什么或做错了什么?
亲切的问候