views:

33

answers:

1

I have a WPF Listbox filled with children that fire events.

Now, I am dynamically loading each of the children but I want to hook up the events to a handler. Basically, each time one of the children give me a notificationEvent(Notification n), I want to add the Notification (n) to an observable collection.

How would I do this so that no matter the amount of children, I can load all the events into the observable collection.

Also, how would you do this in MVVM?

EDIT: All I want to do is simply add all the Notifications that the children gives me to an observable collection.

A: 

Using MVVM, I would expose an ICommand as a property and would then bind the CommandParameter with the list item's bound object. You can check Prism's DelegateCommand for an implementation of an ICommand which receives a delegate to be called on the Execute() method invocation.

Anero
How would you do that? Where would I expose the ICommand? All I want to do is simply add the Notification that the object gives me to an observable collection. Im sorry but I am new to WPF and am not sure what you are trying to say.
AKRamkumar