Binding Events that are Unknown
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 co开发者_StackOverflowllection.
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.
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.
精彩评论