Mvvm combobox绑定Dictionary问题

常规绑定方式:

ViewModel层:  public Dictionary<string, string>MathRelationCollection{ get; set; }//属性

//赋值                          

MathRelationCollection = new Dictionary<string, string>();
MathRelationCollection = DynamicQueryHelper.GetMathCollection();

UI 绑定:ItemsSource="{Binding LogicRelationCollecion}" DisplayMemberPath="{Binding Key, Mode=OneWay}" SelectedValuePath="{Binding Value, Mode=OneWay}"

问题:前台Combobox显示为:[key,value]

解决方法:ItemsSource="{Binding LogicRelationCollecion}" DisplayMemberPath=“Key" SelectedValuePath="Value"

虽然解决了,但为什么会这样,还没想到,也欢迎大家多多提示

原文地址:https://www.cnblogs.com/swarb/p/9924375.html