Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a custom collection object that fires events when items are added, removed and modified.

What I would like to do is each time an item is added, my collection object will discover the events for that item and will create listeners for each event that it finds.

This way the collection object can listen to the events for each item it contains. If an item in the collection fires an event the collection can then fire its own event to bubble that item's event up.

It other words I have collections that contains collections that contains collections and I want to pass events up from a lower collection up to a higher collection till it reaches the top most parent object.

What's a good way to do this?

<edit>I forgot to mention that I am using 2.0 and so I have to wire this up myself.
Posted
Updated 28-Dec-10 8:46am
v3

It sounds like you are creating an ObservableCollection [^]and WPF Routed Events[^]
 
Share this answer
 
If the event is an add event in CollectionChanged event, I would add my events to each item (using the e arguments).

Once these events fire, I would then either pass them onto the parent or handle them here - as required.
 
Share this answer
 
I forgot to mention that I am using 2.0 and so I have to wire this up myself.
 
Share this answer
 
Comments
[no name] 28-Dec-10 9:01am    
This should be added to the original question, not as answer.
Sling Blade 22 28-Dec-10 14:44pm    
Would you have noticed it if I did?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900