我有以下组合框
<ComboBox Grid.Column="1" HorizontalAlignment="Stretch"
Text="{Binding GroupInvoicing.AdminInvoiceBreakdownMembership}"
SelectedValuePath="Tag" SelectedValue="{Binding Path=GroupInvoicing.AdminInvoiceBreakdownMembership}">
<ComboBoxItem Content="None" Tag="N" />
<ComboBoxItem Content="Level of Cover" Tag="L" />
<ComboBoxItem Content="Members" Tag="M" />
<ComboBoxItem Content="Payment Type" Tag="P" />
<ComboBoxItem Content="Work Area" Tag="W" />
</ComboBox>
althogh GroupInvoicing.AdminInvoiceBreakdownMembership以“L”返回,它没有选择相应的文本,也不允许我选择任何内容
d:DataContext="{d:DesignInstance ViewModels:CompanyInvoiceConfigAdminViewModel}"
在viewmodel中我有
public GroupInvoicing GroupInvoicing
{
get
{
return this.groupInvoicing;
}
set
{
if (value != null)
{
this.groupInvoicing = value;
this.OnPropertyChanged(() => this.GroupInvoicing);
}
}
}
AdminInvoiceBreakdownMembership是一个字符串
答案 0 :(得分:3)
我相信你不能将Text和SelectedValue绑定到同一个属性。尝试删除文本绑定。