0

我想将组合框的选定项数据绑定到 ac# 属性。当我执行以下操作时,属性获取值“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();
        }
    }

因为这个属性得到这个值,我绑定错了吗?

4

1 回答 1

1

SelectedChamber属性应该是 type ChamberViewModel,尝试改变它如下:

public ChamberViewModel SelectedChamber
    {
        get { return _selectedChamber; }
        set
        {
            _selectedChamber = value;
            UpdateChart();
        }
    }
于 2013-10-29T08:25:18.810 回答