Solved

Difference between observablecollection and inotifypropertychanged and  INotifyCollectionChanged

Posted on 2010-11-11
3
1,236 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 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