我从服务获得一个KeyValuePair,其中一些值未进行排序,如下所示。如何根据Value对KeyValuePair <string,string>的ComboBox.Items集合进行排序?
我如何通过价值胜地KeyValuePair让他们按字母顺序排列的组合框显示:
public NationalityComboBox()
{
InitializeComponent();
Items.Add(new KeyValuePair<string, string>(null, "Please choose..."));
Items.Add(new KeyValuePair<string, string>("111", "American"));
Items.Add(new KeyValuePair<string, string>("777", "Zimbabwean"));
Items.Add(new KeyValuePair<string, string>("222", "Australian"));
Items.Add(new KeyValuePair<string, string>("333", "Belgian"));
Items.Add(new KeyValuePair<string, string>("444", "French"));
Items.Add(new KeyValuePair<string, string>("555", "German"));
Items.Add(new KeyValuePair<string, string>("666", "Georgian"));
SelectedIndex = 0;
}
服务如何将数据返回给您?一本字典?数组?一个列表?一个单独的对象的负载? – LukeH 2009-10-05 14:34:07
抱歉:集合是KeyValuePair对象的System.Windows.Controls.ItemCollection。 –
2009-10-05 14:44:33