我希望有一个下拉列表框,其中包含代码和定义,但在文本框部分只显示所选项目的定义。例如,在下拉列表中有Y-Yes和N-No,当选择Y时,文本框中只显示Yes。请保留HTML标记。
public class Item
{
public string Key{
get
{
return this.Value[0].ToString();
}
}
public string Value{get;set;}
public override string ToString()
{
return this.Key;
}
}
您可以使用它来显示键和值,如下所示
<ComboBox x:Name="cmbList" ItemsSource="{Binding}" Text="{Binding SelectedItem.Value}"></ComboBox>
我希望这能帮助你解决问题。