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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:34:38+00:00 2026-06-08T16:34:38+00:00

Why ObservableCollection doesn’t has the RemoveAll method like a List ? I have implemented

  • 0

Why ObservableCollection doesn’t has the RemoveAll method like a List?

I have implemented an extension method to provide this functionality to the ObservableCollection, but I would like to understand if there is a specific reason for not providing this functionality.

Would it possibly effect Data Binding in some way due to Collection change? This post does specify a few things that could go wrong while using ObservableCollections, but does not address this question.

  • 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-08T16:34:42+00:00Added an answer on June 8, 2026 at 4:34 pm

    It does have a Clear() method that removes all items that you can use instead.

    If I had to hazard a guess as to why they used Clear instead of RemoveAll, I think it would be because RemoveAll carries the suggestion that you are removing items from the collection, while Clear tells you the items are simply being cleared.

    This makes a difference in the type of CollectionChanged notification that gets raised. Clear() raises a NotifyCollectionChangedAction.Reset event and does not include the removed items in the event, while Remove raises a NotifyCollectionChangedAction.Removed event, and passes the removed item to the event.

    You cannot raise a CollectionChanged event with multiple items, so raising a NotifyCollectionChangedAction.Removed event with all the items removed would throw an exception. The alternative would be to raise a CollectionChanged event for every item that got removed, which can be quite bad for performance. And simply raising a NotifyCollectionChangedAction.Reset event would cause some confusion when users are expecting a Removed event to occur when they are removing items.

    So I am guessing they decided to simply use .Clear() instead of .RemoveAll() because the name is a better description of what is actually happening behind the scenes.

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

Sidebar

Related Questions

I have an ObservableCollection<T> . T has a ToString() method. What I'd like to
This question looks like this one : Programmatically binding List to ListBox but as
I have an ObservableCollection of Task objects. Each Task has the following properties: AssignedTo
I have ObservableCollection<Foo> that is bound to an ItemsControl (basically displaying a list). Foo
I have an ObservableCollection<Object> that contains two different types. I want to bind this
I have a simple ViewModel like: public class MainViewModel { ObservableCollection<Project> _projects; public MainViewModel()
I have this code: public class SelectionList<T> : ObservableCollection<SelectionItem<T>> where T : IComparable<T> {
I have a ViewModel in WPF that looks something like this: public class SwatchViewModel
I have two classes defined like public class PostleitzahlList : ObservableCollection<Postleitzahl> { } public
I have a ObservableCollection property and also this property public ListCollectionView ListView { get

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.