當前位置:成語大全網 - 新華字典 - WPF的combobox綁定數據

WPF的combobox綁定數據

private void Window_Loaded(object sender, RoutedEventArgs e)

{

List<City> list = new List<City>();

list.Add(new City { ID = 1, Name = "上海" });

list.Add(new City { ID = 2, Name = "北京" });

list.Add(new City { ID =3, Name = "天津" });

cmb_list.ItemsSource = list;

}