我有一个包含四列的数据网格。
Mongoose: parentRecord.update({ _id: ObjectId("5551895182d9adbe1da34d6a") }) { '$inc': { __v: 1 }, '$set': { anotherField: 'anotherValue' }, '$pushAll': { fields: [ { _id: ObjectId("55518c682a0744dc20f1473b"), value: 'bar', name: 'foo' } ] } } {}
模型类<DataGrid ItemSource="{Binding MyDataSet,Mode=TwoWay}">
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock ...../>
</DataTemplate>
</DataGridColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock ...../>
</DataTemplate>
</DataGridColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
.............
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemSource ="{Binding FirstComboBoxData }" SelectedItem="{Binding FirstComboBoxSelectedVal}"/>
</DataTemplate>
</DataGridColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DataTemplate>
<ComboBox ItemSource ="{Binding SecondComboBoxData }" SelectedItem="{Binding SecondComboBoxSelectedVal}"/>
</DataTemplate>
</DataGridColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
如下所示。
MyData
然后我的ViewModel中有以下列表。
class MyData : ObservableObject
{
private string _code;
public string Code
{
set { _code = value ; OnPropertyChanged("Code");}
get { return _code ;}
}
private string _name;
public string Name
{
set { _name = value ; OnPropertyChanged("Name");}
get { return _name ;}
}
private List<SomeOtherClass> _firstComboBoxData;
public List<SomeOtherClass> FirstComboBoxData
{
set { _firstComboBoxData = value ; OnPropertyChanged("FirstComboBoxData");}
get { return _firstComboBoxData ;}
}
private List<SomeOtherClass> _secondComboBoxData;
public List<SomeOtherClass> SecondComboBoxData
{
set { _secondComboBoxData = value ; OnPropertyChanged("SecondComboBoxData");}
get { return _secondComboBoxData ;}
}
private SomeOtherClass _firstComboBoxSelectedVal;
public SomeOtherClass Name
{
set { _firstComboBoxSelectedVal= value ; OnPropertyChanged("FirstComboBoxSelectedVal");}
get { return _firstComboBoxSelectedVal;}
}
private SomeOtherClass _secondComboBoxSelectedVal;
public SomeOtherClass SecondComboBoxSelectedVal
{
set { _secondComboBoxSelectedVal= value ; OnPropertyChanged("SecondComboBoxSelectedVal");}
get { return _secondComboBoxSelectedVal;}
}
}
class SomeOtherClass
{
private int id;
public int ID
{
set { id = value ; OnPropertyChanged("ID");}
get { return id ;}
}
}
我看到一切都很好。但是,当我更改所述组合框的所选项目时, private ObservableCollection<MyData> _myDataSet;
public ObservableCollection<MyData> MyDataSet
{
set { _myDataSet=value; OnPropertyChanged ("MyDataSet"); }
get { return _myDataSet ;}
}
相关的MyDataSet
或FirstComboBoxSelectedVal
未更新
我在某处做错了吗?