我從服務獲得一個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