我想将组合框的选定项目数据绑定到c#属性。当我执行以下操作时,该属性获取值“Suite.Module.RateExperiment.ViewModels.ChamberViewModel”(这不是组合框中所选项目的值):
<ComboBox DisplayMemberPath="ChamberName" Grid.Column="0" Grid.Row="1" Height="20" VerticalAlignment="Top" ItemsSource="{Binding ChamberCollection}" SelectedValue="{Binding SelectedChamber}">
</ComboBox>
和c#:
public string SelectedChamber
{
get { return _selectedChamber; }
set
{
_selectedChamber = value;
UpdateChart();
}
}
我绑定错误,因为此属性获取此值?
答案 0 :(得分:1)
SelectedChamber
属性应为ChamberViewModel
类型,请尝试按以下方式进行更改:
public ChamberViewModel SelectedChamber
{
get { return _selectedChamber; }
set
{
_selectedChamber = value;
UpdateChart();
}
}