DataGrid/ObservableCollection OneWay binding issue

Mar 18, 2009 at 3:01 PM
Greetings,

I'm looking for a little guidance with a problem I'm having.  I have a DataGrid on my UI side, and an ObservableCollection on the backend.  I populate the ObservableCollection with custom data objects.  Here's the catch, I have separate threads populating the data in my custom data objects, which return data at different times.  I was hoping that the INotifyCollectionChanged interface would pick up on changes made to the data properties of my custom objects.  After looking in to it some more, I'm guessing that is not how this is designed.  I see that the DataGrid gets notified on the following actions:

Add, Remove, Replace, Move, and Reset (based on records, not record properties).

My intended design is to have a read only DataGrid with a OneWay binding to the collection of my custom objects.  Then once a data field changes on any of my custom objects, the DataGrid would reflect that change and modify the appropriate cell to display the new value.  I haven't tried this yet, but I guess I could create a custom collection object that implements the INotifyCollectionChanged interface, and then raise the CollectionChanged event with a Reset action every time a piece of data is populate on my custom objects.

What would be our best practice in this situation? 
Thank you for your time,
-Dave Fribley
Mar 18, 2009 at 5:13 PM
Roel,

Thank you.  Your advice does help a lot and is setting me on the right track.  My first mistake was that I hadn't implemented the INotifyPropertyChanged on my custom objects.  After implementing that, I switched over to using a BindingList<T> object for my collection.  It worked great and I feel a lot more comfortable about the BindingList's ListChanged event.  It looks to be more what I'm trying to do with the "ItemChanged" change type.

Thanks again!  Great Advice.
-Dave