|
-
Nov 2nd, 2021, 10:10 AM
#2
Re: Shared data and Models Advice
Without being two specific, the approach I would be inclined to take would be to have a single object that holds the data from the file. It is responsible for getting the data from the file and storing the data back to the file. It would also have events that get raised whenever the data is changed. It sounds like the data is only changed from one of the three user controls, but whether or not that provides any advantages is hard to say. When a change is made to the data, the object should raise an event to indicate this. It could be a very simple 'datachanged' event that has no real information associated with it other than the fact that the data changed. The other controls would handle that event and know to redraw themselves when it happens. Of course, if there is information that could be included in the event that would make it easier for the controls to redraw, then it might make sense to include that information, but it also might not. The controls should be capable of redrawing based on the state of that data object, regardless of what that state is, so there's no point in tying your code in knots to make for a bunch of special cases.
My usual boring signature: Nothing
 
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|