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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:42:05+00:00 2026-06-09T06:42:05+00:00

I was looking around in ObservableCollection<T> using a decompiler and saw some curious OnPropertyChanged

  • 0

I was looking around in ObservableCollection<T> using a decompiler and saw some curious OnPropertyChanged code that I’d never seen before.

public class ObservableCollection<T> : Collection<T>, INotifyCollectionChanged, INotifyPropertyChanged
{    
    private const string IndexerName = "Item[]";

    protected override void ClearItems()
    {
        ...
        base.OnPropertyChanged("Count");
        base.OnPropertyChanged("Item[]");
        ...
    }
}

What does the OnPropertyChanged("Item[]") call do and how would that be helpful when writing my own code?

It must be doing something different than a standard OnPropertyChanged call since ‘Item’ is not a property on the object and ‘[]‘ surely isn’t part of ‘any’ property name.

  • 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-09T06:42:07+00:00Added an answer on June 9, 2026 at 6:42 am

    The call to OnPropertyChanged("Item[]") is required to follow the spirit of INotifyPropertyChanged. The data returned by the default indexer Item has changed.

    In your specific example, the collection has been cleared, so if you are indexing into a specific item the collection, then you need to be notified that the object reference you are interested in may be different.

    Edit

    After Kevin’s comment about binding to an indexer, I wrote an app to test the binding.

    I created an ObservableCollection<int> and populated like this:

    this.Indexed.Add(1);
    this.Indexed.Add(2);
    this.Indexed.Add(3);
    

    If you bind to something via the indexer like this, it will display 3:

    <TextBlock Text="{Binding Indexed[2]}" />
    

    And then change the object at that index at runtime,

    this.Indexed.Insert(2, 10);
    

    The TextBlock will update and display the new value 10.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been looking around some time for a very simple implementation using DotNetOpenAuth to
I've been looking around trying to determine some Hibernate behavior that I'm unsure about.
I've been looking around but I haven't seen anything that addresses this so I'm
Looking around SO user profiles and other sites, I have noticed that some high
Looking around the web, I've seen this simple pattern that implements a (thread-safe) singleton
Looking around, I can't name a single web application (not web service) that uses
I have been looking around for a visualization framework that would aid graph visualization
I've been looking around for a log4j viewer that allows for multiple log files
Looking around at different code bases I see a variety of styles: Class interfaces
Looking around for python implementations of tries just so that I can understand what

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.