Real quick on observable collections. I’ve been playing around with these in Silverlight doing some binding stuff, what have ya. Seems like the CollectionChanged event fires when removing from or adding to the collection. I’d like for something to fire when I change a property on one of the classes inside the collection. The collection property itself already has the RaisePropertyChanged. Do I need to do something special to the type class itself? So if I have this:
ObservabelCollection<Person> personcollection... and if I change a property like:
Person p = personcollection.where(e => e.FirstName == "Joey").FirstOrDefault();
if (p != null) { p.FirstName = "Joe"; }
I would expect something to happen in the UI but nothing changes.
Any help would be greatly appreciated.
David
I see what you’re trying to do but if im correct Observable Collection only raises the
INotifyCollectionChangedevent when items in it’s collection changes. This will trigger changes in the UI.It doesn’t care if a property on one of it’s objects in it’s collection changes. You would need to implement the
INotifyPropertyChangedInterface on the properties on these objects to trigger a change to the UI.I had a read of here which gave me some useful insight. Though it is aimed for WPF most of it still applies as Silverlight is essentially a subset of WPF.
As well as this MSDN article which states: