Binding a parent to an event of a child (list)

Binding a parent to an event of a child (list)

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


triplea posted on Thursday, July 19, 2007

I have seen a couple of posts wherein it was mentioned that if a parent needs to act when a child is modified, its good practice to capture the modification event of the child from the parent and act then.
In my case I have something like: Customer (Editable Root) - Orders (Child list of Order objects). I need to set a value on Customer when a specific Order type is added.
In the Initialize() method of Customer I added this: this._orders.ListChanged += <event handler> as well as override the OnListChanged on Orders. Although OnListChanged is fired, the event handler of _orders.ListChanged never does. Makes me wonder what I have done wrong here...

RockfordLhotka replied on Friday, July 20, 2007

If you override OnListChanged, you must call base.OnListChanged or you will have prevented the event from being raised.

Copyright (c) Marimer LLC