It is rather a design issue.
I create a tool that displays business objects in different ways (for example, tree nodes, list view items, combo fields, text fields, etc.). Each time a user changes one of them, an event occurs that signals that this business object has been changed or the collection to which it belongs has been changed. Since this business object or collection to which it belongs can be displayed in more than one place, each of these user interface elements must be updated to reflect this change. Is there an elegant decision to properly update each type of user interface element in case of a change?
I have a few ideas on how this can be done, but I would like to know if anyone has this problem, and was pleased with their solution. This is C # WinForm, but the solution can be in any language.
My current thoughts on the problem and possible solution:
This gets complicated when you want to clear event bindings (i.e. businessObject.Changed - = ObjectChanged) when your business objects become part of TreeNodeCollection / ListViewITemCollection / ComboBoxItemCollection and Clear () is called in the collection.
How about a "Service", where each object and its ui element can be registered, where the events of a business object can be listened to in one place, and each element of the user interface will be updated when events are raised? When all user interface elements are unregistered, the subscription to this object event is deleted.
, , .
?
SpikedPunchVictim