Rich

Rich

  • NA
  • 84
  • 61.3k

Display Member Path

Oct 19 2011 7:20 PM
I am trying to populate a wpf ComboBox with my foreach block. When I run the program I can see that that the combobox has made space for the query/items but it is blank. I have verified that my linq query does in fact return items via a message box. Not sure what to do at this point as my code returns no errors either. Thanks in advance for your time and assistance.

var AwayQuery = from allTeams in ComboBoxEnt.AllTeams
                            where (allTeams.Sport == "Football") && (allTeams.Lvl == "Pro")
                            && (allTeams.League == "NFL")
                            select new
                            {
                                MLB = allTeams.MLB_Teams,
                                NFL = allTeams.NFL_Teams
                            };
            if (AwayQuery.Count().ToString() == "0")
            {
                MessageBox.Show("nothing returned");
                apAwaySelect.Text = "Select Query";
            }
            else
            {
                MessageBox.Show(AwayQuery.Count().ToString());
            }

            foreach (var teamItem in AwayQuery)
            {
                if (teamItem.MLB != null)
                {
                    apAwaySelect.Items.Add(teamItem.MLB);
                    apAwaySelect.DisplayMemberPath = "MLB";
                   
                }
                else
                {
                    apAwaySelect.Items.Add(teamItem.NFL);
                    apAwaySelect.DisplayMemberPath = "NFL";
                   
                }
            }

Answers (1)