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

  • Home
  • SEARCH
  • 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 6209375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:58:25+00:00 2026-05-24T05:58:25+00:00

I have some issue with WPF databinding, and I hope to be clear in

  • 0

I have some issue with WPF databinding, and I hope to be clear in my explaination because I fear that the problem is very subtle.

I have essentially a WPF UserControl with a bunch of ComboBox, each one is chained to each other. I mean that the first combobox is filled with some elements, and when the user select and item, the second combobox is filled with elements based on the previous selection, and so on with other combox.
All combobox are binded with UpdateSourceTrigger=LostFocus.

The code for a ItemsSource property of a combo looks like this:

    private ICollectionView allTicketTypesView;
    public IEnumerable<TicketTypeBase> AllTicketTypes
    {
        get { return this.allTicketTypesView.SourceCollection.Cast<TicketTypeBase>(); }
        private set
        {
            IEnumerable<TicketTypeBase> enumerable = value ?? new TicketTypeBase[0];
            ObservableCollection<TicketTypeBase> source = new ObservableCollection<TicketTypeBase>(enumerable);
            this.allTicketTypesView = CollectionViewSource.GetDefaultView(source);
            this.OnPropertyChanged("AllTicketTypes");
        }
    }

The code for a SelectedItem property of a combo is similar to this code:

private TicketTypeBase ticketType;
public TicketTypeBase TicketType
{
    get { return this.ticketType; }
    set
    {
        this.ticketType = value;
        this.OnPropertyChanged("TicketType");
        this.UpdateConcessions();
    }
}    

I’m experiencing a subtle problem:
when i move with keyboard and/or mouse over my combo, I see that often propertychanged is called also when I actually don’t change any of the items of the list.
I mean that a combo is filled with elements, and an item is selected: moving over the combo with the keyboard trigger the propertychanged (and let the other combo to be updated, that is an indesidered behavior), but the element itself is the same.
I see this behavior in a combobox that is binded with a list of strings (so I suppose no error on Equals/GetHashCode implementation) and this behavior happens everytime except the first time.

I’ve fixed the code with this:

    private string category;
    public string Category
    {
        get { return this.category; }
        set
        {
            bool actuallyChanged = !String.Equals(this.category, value);
            this.category = value;
            this.OnPropertyChanged("Category");

            if (!actuallyChanged)
            {
                string format = String.Format("Category '{0}' isn't changed actually", value);
                Trace.WriteLine(format);
            }
            else this.UpdateTicketTypes():
        }
    }

But of course I don’t like this code that add logic to the setters.

Any suggestion about how to avoid this behavior?
I hope to be clear, and I’m ready to explain better my problem if someone don’t understand clearly.

  • 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-05-24T05:58:25+00:00Added an answer on May 24, 2026 at 5:58 am

    It is not unreasonable for your model to check whether a value used in a property setter is actually different from the current value. However a more ‘standard’ implementation would look like the following:

    private string category;
    public string Category
    {
        get { return this.category; }
        set
        {
            // check this is a new value
            if(Object.Equals(this.category, value))
                return;
    
            // set the value
            this.category = value;
            // raise change notification
            this.OnPropertyChanged("Category");
            // compute related changes
            this.UpdateTicketTypes():
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a design issue that I would appreciate some input on. I would
I have some WinForms controls that I need to use in a WPF window.
I have a performance issue with the WPF DataGrid (.net 4.0) first, some details:
I have a very strange issue in my WPF project. The main window contains
I am successfully databinding and using WPF Comboboxes and have had some success with
I have run into an issue with WPF and Commands that are bound to
I have some issue with a Perl script. It modifies the content of a
I have some unsolved issue with threads. It's my first time doing it. I
i have an issue i could use some help with, i have python list
I have an issue with System.Threading.Timer. I am scheduling some actions using a time

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.