Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Difference between observablecollection and inotifypropertychanged and  INotifyCollectionChanged

Posted on 2010-11-11
3
Medium Priority
?
1,275 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 1000 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 1000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

636 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