我有这段代码,但ComboBox
中仍然没有数据。
using (var context = new DatabaseContext())
{
var xd = (from c in context.CHall
orderby c.CinemaHallName
select c).ToList();
foreach (var c in xd)
{
cbCinemaHall.ItemsSource = c.CinemaHallName;
cbCinemaHall.DisplayMemberPath = "CinemaHallName";
}
}
答案 0 :(得分:1)
为此目的,您不需要foreach
。只需将ItemsSource
的{{1}}设置为ComboBox
即可。像这样:
xd