private void FillComboBox() { List <TeamsPage.Team> timovi = APIParser.ParseTeams(checkSelectedCup()); foreach (TeamsPage.Team team in timovi) { cbTimovi.Items.Add(team); } cbTimovi.DisplayMember = "Country"; cbTimovi.ValueMember = "FifaCode"; cbTimovi.DataSource = timovi; }
private void FillCbHomeTeam() { try { Dictionary <string, string> dictionary = new Dictionary <string, string>(); List <TeamsPage.Team> teams = APIParser.ParseTeams(GetPage()); foreach (var item in teams) { dictionary.Add(item.Country.ToString(), item.FifaCode.ToString()); } cbHomeTeam.ItemsSource = dictionary; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); throw; } }
private void BtnHomeTeam_Click(object sender, RoutedEventArgs e) { if (cbHomeTeam.SelectedItem != null) { KeyValuePair <string, string> par1 = (KeyValuePair <string, string>)cbHomeTeam.SelectedItem; List <TeamsPage.Team> teams = APIParser.ParseTeams(GetPage()); TeamsPage.Team team = new TeamsPage.Team(); foreach (var item in teams) { if (par1.Value.ToString() == item.FifaCode) { team = item; } } DetailedTeam detailedTeam = new DetailedTeam(team); detailedTeam.Show(); } else { MessageBox.Show("Odaberite tim iz comboboxa"); } }