Assume I have a canvas that has rendered shapes. I can drag-move around that canvas as if I was in a zoomed in image to move all shapes around. Between the Model and ViewModel I have a ServiceLayer (or Controller, however you'd like to call that ) that generates shapes based on generic object-logic and applies the necessary styles, which it then feeds to the ViewModel. Although not completely traditional MVVM, it's the solution I came up with thinking about how to change the CanvasBehaviour at runtime without switching ViewModels. Now if I want to switch the underlying generic service (perhaps because another tool was selected) I need to save what the current center position is.
It seems like a nitpicky question, but I feel like since I cannot answer this fully and with determination, I might have misunderstood something about the architecture. Here's what I'm thinking:
- It should not be saved in the Model. The model is for all the underlying shapes etc. and has nothing to do with how they're displayed.
- It should not be in the ServiceObject, since it can change dynamically at runtime based on tools and it "feels" wrong to read out the previous center and feed it to a new ServiceObject before replacing it.
- It might belong in the ViewModel. the ViewModel prepares the data it receives into the necessary binded collections. I can keep a reference of the center here, and modify the incoming shapes etc. to translate them around this center point. However that means that the "move" tool now needs a reference towards this ViewModel, to tell it how it changed or similarily, but the tools are supposed to be contained in the ServiceObject entirely.
- It does definitely not belong in the view, I think.