This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have an object graph in which a parent object has a collection of child objects. Both parent and child have various calculated fields who's values depend on the other object. When adding/removing children to the parent, I am using (amongst others) the EntityAdded event to trap the addition and fire off my code to update the calculated fields. The issue I'm having is that the EntityAdded event fires after the child object is placed in the parent's EntityCollection (good), but before the child has had it's backreference set (ie: child.parent == NULL == bad). This seems counter-intuitive to me, and means I can't easily get the child to update its calculated properties that depend on the parent (because it doesn't have a reference to the parent yet). Is there a reason for this behaviour, or might it be a bug? Is there another way to use the event system to achieve what I want?
|
|
|
There is a reason, but it's an internal implementation detail (we use the EntityAdded event to trigger the wiring of the backreference, so the backreference won't be wired up during event handlers that run earlier in the chain). From looking at the code, the EntityCollection.ItemAdded event is fired after EntityAdded has run to completion. So ItemAdded event handlers *should* see the backreference wired up. Please note I have not tested this. Also note that EntityCollection.ItemAdded may not show up in Intellisense but it is there really! |
|
|
Thanks, that worked. You're correct, the ItemAdded / ItemRemoved events don't appear in intellisense*. Is there some documentation somewhere that details all the available events?
*NB: I've just switched to using Resharper, and discovered these events do appear in intellisense with Reshapers 'enhanced' intellisense enabled.
|
|
|
Cool, glad to hear that worked. For full API documentation, see "User Guide and API Reference" on the Start menu. This only provides MSDN-style API docs though; if you're after a more "lifecycle" presentation of the events, I'm afraid that doesn't currently exist. |
|