Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7909201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:18:18+00:00 2026-06-03T12:18:18+00:00

I’m attempting to create a small application in which I can make a poul

  • 0

I’m attempting to create a small application in which I can make a poul for the coming Europian Soccer Championship.

For this, I need to add matches ofcourse.

What I wish for is to have 3 comboboxes where the first is set by what type of match it is (Poule A, Poule B etc). After that combobox has been set, I want the next two comboboxes only to show the teams that are in those poules.

I believe this can be done using converters but I can’t seem to get it to work.. or is there a better approach ?

current code:

<ComboBox ItemsSource="{Binding MatchTypes}"
                        DisplayMemberPath="TypeName"
                        Grid.Row="1" />

<ComboBox ItemsSource="{Binding Teams}"
                        DisplayMemberPath="TeamName"
                        Grid.Column="1"
                        Grid.Row="1" />

<ComboBox ItemsSource="{Binding Teams}"
                        DisplayMemberPath="TeamName"
                        Grid.Column="2"
                        Grid.Row="1" />

Is there a simple way (linq?) to query the last two comboboxes for only the teams that are in the poule selected in the first combobox?

If possible, I prefer to keep this out of the viewmodel and use a converter or something similar.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:18:22+00:00Added an answer on June 3, 2026 at 12:18 pm

    Personally, I would keep this in the viewmodel code. I have done something similar, so here it is, mapped to what you are doing:

    • I have a pre-populated list of items in my viewmodel. This would be MatchTypes.

    • I would have another property called CurrentMatchType, using INotifyPropertyChanged when it is set.

    • When the value of CurrentMatchType is set, it would call out to the datasource and populate the other two lists on the viewmodel. We also have 2 variable called PouleA and PouleB, representing the final team selections. We will call the lists you just grabbed from the server TeamsA and TeamsB. It’s the same data for both lists, but I would set the data source result to an internal value and then set TeamsA to the list of all teams except the one selected in PouleB, and the list of TeamsB to the list of all the teams except the ones in PouleA. This way, one team cannot be matched by themselves.

    • One last thing I forgot: On the setter of PouleA and PouleB, you would run the same code as above to filter the available teams so the opposite team is also excluded. Since INPC is hooked up to everything, your comboboxes will all change automatically.

    • When I grab data from a datasource, I expose a property to have a BusyIndicator take over the screen so nothing can be touched until it’s done grabbing data.

    I’m in the camp that thinks trying to use a converter for things like this adds unnecessary frustration. If you don’t want to add it to your viewmodel because you’re reusing it in different places, there’s nothing stopping you from making a new viewmodel that exposes the old viewmodel as a property.

    PSEUDO-CODE

    using System;
    
    /* In your model... */
    
    public sealed class MatchType
    {
        public string Name { get; internal set; }
        public string Description { get; internal set; }
        public int ID { get; internal set; }
    }
    
    public sealed class Team
    {
        public string Name { get; set; }
        public MatchType MatchType { get; set; }
        public int? MatchTypeID { get; set; }
        public int ID { get; set; }
    }
    
    /* In your viewmodel... */
    
    public sealed class TeamSelection
    {
    
        // These two should be INotifyPropertyChanged, shortened for this example.
        public MatchType[] MatchTypes { get; private set; }
        public Team[] TeamsA { get; private set; }
        public Team[] TeamsB { get; private set; }
    
        private Team[] teams = null;
        MatchType matchType = null;
        public MatchType SelectedMatchType {
            get { return matchType; }
            set
            {
                if (value != null)
                    matchType = value;
                else if (MatchTypes != null && MatchTypes.Length > 0)
                    matchType = MatchTypes[0];
                else
                    return;
                PropertyHasChanged(() => SelectedMatchType);
                PopulateTeams();
            }
        }
    
        Team teamA;
        Team teamB;
    
        public Team SelectedTeamA 
        {
            get { return teamA; }
            set
            {
                if (teamA.ID == teamB.ID)
                    // Alternatively, set a flag and stop execution.
                    throw new InvalidOperationException("The same team cannot be selected.");
                teamA = value;
                PopulateTeams();
                PropertyHasChanged(() => SelectedTeamA);
            }
        }
    
        public Team SelectedTeamB 
        {
            get { return teamB; }
            set
            {
                if (teamA.ID == teamB.ID)
                    // Alternatively, set a flag and stop execution.
                    throw new InvalidOperationException("The same team cannot be selected.");
                teamB = value;
                PopulateTeams();
                PropertyHasChanged(() => SelectedTeamB);
            }
        }
    
        /// <summary>
        /// This can be done on your model, or what I do is pass it to 
        /// an intermediary class, then that sets the busy status to
        /// a BusyIndicator set as the visual root of the application.
        /// </summary>
        public bool IsBusy { get; private set; }
        public string IsBusyDoingWhat { get; private set; }
    
        public TeamSelection()
        {
            // Call out to DB for the match types, setting busy status
            var wcf = new WcfService();
            wcf.GetMatchTypes(response => 
            {
                wcf.GetMatchTypesForTeam(MatchType, response2 =>
                {
                    teams = response.Value.ToArray();
                    MatchTypes = response2.Value.ToArray();
                    MatchType = MatchTypes[0];
                    PopulateTeams();
                });
            });
        }
    
        void PopulateTeams()
        {
            if (MatchType == null)
                return;
            var op = teams.Where(t => t.MatchTypeID == MatchType.ID);
            if (SelectedTeamA != null)
                TeamsB = op.Where(t => t.ID != SelectedTeamA.ID).OrderBy(t => t.Name);
            else
                TeamsB = op.OrderBy(t => t.Name);
            if (SelectedTeamB != null)
                TeamsA = op.Where(t => t.ID != SelectedTeamB.ID).OrderBy(t => t.Name);
            else
                TeamsA = op.OrderBy(t => t.Name);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.