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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:05:02+00:00 2026-06-03T03:05:02+00:00

I have an observable collection and I have a collectionChanged event wired up on

  • 0

I have an observable collection and I have a collectionChanged event wired up on that.
I have its items bound to a listbox in the UI.
When the user removes some items in the UI from the listbox, the CollectioChanged gets fired properly, however, I need to know the indices of the items that were removed.
The problem is I am not able to an indexOf on the collection after it is changed because it does not have the removed item anymore..

Can we get access to the list of indexes that were removed from an ObservableCollection from the collectionchanged event?

  • 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-03T03:05:04+00:00Added an answer on June 3, 2026 at 3:05 am

    The CollectionChanged event uses an event that gives you a NotifyCollectionChangedEventArgs. This has a OldStartingIndex property, which will tell you the index it was removed at. For example:

    void Foo()
    {
        ObservableCollection<string> r = new ObservableCollection<string>();
        r.CollectionChanged += r_CollectionChanged;
    }
    
    static void r_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
    {
        var itemRemovedAtIndex = e.OldStartingIndex;
    }
    

    Assume that I am removing MULTIPLE items from the collection at different indices..So using the oldStartingIndex would just give me the first item index that was removed

    The event will most likely fire multiple times, once for each item.

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

Sidebar

Related Questions

I have an observable collection bound to a listbox in WPF. One of the
I have an observable collection that is exposed to the user by a collectionviewsource.
I have an ItemsControl that is populated with an observable collection of some ViewModel
I have one observable collection with user control. And I am bind it in
The situation is like this: I have an Observable Collection that has a bunch
I'm stumped here. I have an observable collection that holds business objects. I have
I have a WPF ItemsControl who's ItemsSource is bound to an observable collection of
In a dialog from my application, I have an observable collection (stored somewhere else)
I have a observable collection of type Project, that I want to be displayed
I bind observable collection on listBox. I have data tempate on listbox item. It

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.