I am now refactoring a code written by someone else and I have found a construct that I have mixed feelings about. There is a ListView-like control and each of its items can raise 'DialogOpened' event. However, it may be cumbersome to register external event handlers to each of the items (and the items may be added or removed dynamically!). For that reason there is a single event in the ListView-like control and it is named 'ItemDialogOpened'. It sounds all reasonable for me, but there are two issues:
- There is a method 'OnItemDialogOpened' in the ListView-like control raising the single event, but this method is not called directly. Instead, it is registered as an event handler to 'DialogOpened' event of each item. It that ok? I am asking, because I was unable to find anything similar to it in the MSDN.
- If such event redirection is ok, then who should be the sender of that final, single event? Now, in the code I am working with it is the original sender - the item. However, I think (but I am not sure about it), that now the sender should be changed to the ListView-like control. Am I right?