我正在开发一个 Windows 8 应用商店应用程序 (c#)。我有一个从存储库中获取项目的组合框(cboTeam1)。
private static List<TeamItem> JPLItems = new List<TeamItem>();
public static List<TeamItem> getJPLItems()
{
if (JPLItems.Count == 0)
{
JPLItems.Add(new TeamItem() { Id = 1, Description = "Anderlecht", Image = "Jpl/Anderlecht.png", ItemType = ItemType.JPL });
JPLItems.Add(new TeamItem() { Id = 1, Description = "Beerschot", Image = "Jpl/Beerschot.png", ItemType = ItemType.JPL });
JPLItems.Add(new TeamItem() { Id = 1, Description = "Cercle Brugge", Image = "Jpl/Cercle.png", ItemType = ItemType.JPL });
JPLItems.Add(new TeamItem() { Id = 1, Description = "Charleroi", Image = "Jpl/Charleroi.png", ItemType = ItemType.JPL });
}
return JPLItems;
}
我在 cboTeam1 的 ItemsSource 中加载项目:
cboTeam1.ItemsSource = ItemRepository.getJPLItems();
当 cboTeam1 selectionchanged 我这样做:
private void cboTeam1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Ploeg1.Text = cboTeam1.SelectedValue.ToString();
}
这导致:SportsBetting.Model.TeamItem
任何人都可以帮我在我的文本块(Ploeg1.Text)中获取组合框 selectedvalue 吗?