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 1026631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:06:45+00:00 2026-05-16T12:06:45+00:00

I was learning about ObservableCollections in WPF and something is not clear to me.

  • 0

I was learning about ObservableCollections in WPF and something is not clear to me. I understand that if I bind a control to an ObservableCollection and the collection changes, the control will reflect the changes. My questions are:

  • ObservableCollection implements INotifyCollectionChanged, which is just an event, CollectionChanged. That event should be fired whenever the collection changes but who subscribes to that event? Is it done automatically when you create a binding to the collection?

  • I was looking at ObservableCollection using Reflector and was trying to see when the CollectionChanged event gets fired. However I couldn’t find where it is done. For example, I wanted to see when it was fired when I added a new item to the collection. Add(…) is implemented in ObservableCollection’s base class, Collection, but Collection does not implement INotifyCollectionChanged so I don’t understand how bound controls are notified of the change.

I am guessing that a lot of this is taken care of under the covers but any info is greatly appreciated.

  • 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-16T12:06:46+00:00Added an answer on May 16, 2026 at 12:06 pm

    To answer your first question: it all starts inside the “Items” property of the ItemContainerGenerator class (which, all ItemsControl objects have an instance of). If you look at the setter for the said “Items” property, you’ll see that it has special logic that checks if the given IList is of type INotifyCollectionChanged, it will attach an event listener.

    ItemContainerGenerator.Items property:

    
    internal IList Items
    {
        get
        {
            return this._items;
        }
        set
        {
            if (this._items != value)
            {
                INotifyCollectionChanged source = this._items as INotifyCollectionChanged;
                if ((this._items != this.Host.View) && (source != null))
                {
                    CollectionChangedEventManager.RemoveListener(source, this);
                }
                this._items = value;
                source = this._items as INotifyCollectionChanged;
                if ((this._items != this.Host.View) && (source != null))
                {
                    CollectionChangedEventManager.AddListener(source, this);
                }
            }
        }
    }
    
    

    It really has nothing to do with Bindings. See, if you have the following code that doesn’t use Bindings at all, the collection changed notification will still work:

    <Window x:Class="DynamicObjectTest.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <StackPanel>
                <Button Click="Button_Click">click</Button>
                <ListBox x:Name="listBox"/>
            </StackPanel>
        </Grid>
    </Window>
    
    
    public partial class MainWindow : Window
        {
            ObservableCollection items = new ObservableCollection();
    
            public MainWindow()
            {
                InitializeComponent();
    
                this.listBox.ItemsSource = items;
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                items.Add("A");
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Where should I start learning about version control systems? I've used SVN, Team Foundation,
I'm just learning about SVG, and it seems great but I'm not sure about
After learning about source control the first thing I did is do a project
I am learning about NServiceBus and MSMQ. I was told that transactional queues in
In learning about Web Deploy I came across some netsh.exe commands that talk about
Just learning about mercurial's --style and --template options that can be used on hg
I'm learning about the android. Now, I want to display a button that can
I'm just learning about them, and find it discouraging that they have been deprecated.
I'm currently learning about class inheritance in my Java course and I don't understand
Learning about ARM NEON intrinsics, I was timing a function that I wrote to

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.