I have a project that is using CSLA 3.02.
I have a BLB object that has child items that have an IsDefault property.
When a child object has its IsDefault property set to true, I want to set the other child members IsDefault property to false.
I am calling the OnPropertyChanged("IsDefault") in the setter and I have that raising the Collections ListChanged event. However, the sender of the event is the Collection object, not the child object that raised the event. Nor is the child item in the ListChangedEventArgs (e).
How do I get a reference to the specific child instance that raised the event?
Or should I be doing this some other way?
Any help is appreciated.
The ListChanged event is a Microsoft .NET event from the standard list base class, it isn't a CSLA thing.
In later versions of CSLA we implemented ChildChanged events to provide richer information about changes to child objects/collections.
I would implement this type of logic in an override of the OnListChanged method in the list or attach an event handler to the list.
ListChangedEventArgs provide a property NewIndex which is the index to the item that was changed (or added) in the list.
So you can use this index to get the actual child item that was changed.
Copyright (c) Marimer LLC