How do you get CSLA 3.02 BusinessListBase ListChanged event to identify the child object whose OnPropertyChanged triggered the event?

How do you get CSLA 3.02 BusinessListBase ListChanged event to identify the child object whose OnPropertyChanged triggered the event?

Old forum URL: forums.lhotka.net/forums/t/12251.aspx


SethSpearman posted on Wednesday, December 04, 2013

Hello,

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.

Seth

RockfordLhotka replied on Saturday, December 07, 2013

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.

JonnyBee replied on Sunday, December 08, 2013

Hi, 

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