Solved

Difference between observablecollection and inotifypropertychanged and  INotifyCollectionChanged

Posted on 2010-11-11
3
1,252 Views
Last Modified: 2013-12-17
Hi Friends,

Can you please help me in understanding

Difference between observablecollection and inotifypropertychanged and
'  INotifyCollectionChanged

Thankyou
0
Comment
Question by:N_Sri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 250 total points
ID: 34115999
INotify... are both interfaces.  Classes that implement these interfaces must implement methods, properties and events that are described in the interface.  This allows code to be guaranteed of methods that an object supports.  For example, all objects that implement IDisposable are known to have a method named "Dispose" (because Dispose is defined in the interface).  That allows me to write a method that takes an IDisposable parameter, and I don't need to know or care if the object passed to my method is a Stream, database connection, etc - all I know is that this object implements IDisposable, therefore I know I can call .Dispose()
void someMethod(IDisposable someObject)
{
    someObject.Dispose();
}
ObservableCollection is a class that implements the two interfaces - it uses events to notify you when the contents of the collection it represents have changed.
http://msdn.microsoft.com/en-us/library/ms668604.aspx
http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx
http://msdn.microsoft.com/en-us/library/system.collections.specialized.inotifycollectionchanged.aspx 
0
 
LVL 16

Assisted Solution

by:ToddBeaulieu
ToddBeaulieu earned 250 total points
ID: 34119754
Additionally,

Many of the UI controls are designed to be bound to a datasource that lets it know when rows are added, changed or removed. This is done via the INotifyCollectionChanged  interface. I suspect the inotifypropertychanged  interface in this case is used to signal changes to the collection property itself (like the Count property).

In your code you'll probably end up just using OCs, but framework and reusable code typically calls for a INotifyCollectionChanged  data source, because many data sources can implement this interface ... not just the OC. In fact, you could easily write your own class that implements this interface and can be bound to a UI control.
0
 

Author Closing Comment

by:N_Sri
ID: 34141051
thankyou
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question