Persisting diagram properties?

I’m deriving my model class from GraphLinksModel and I see how one can override the GraphLinksModelNodeData.MakeXElement and LoadFromXElement methods to persist custom node properties. However, I want to persist properties such as Diagram.Panel.Scale and Diagram.Panel.Position so I can restore the precise view that was saved by the user. What’s the best way to go about doing that? I had thought to override a GraphLinksModel.MakeXElement method, but such a method does not seem to exist.

Well, first, the idea of the model/view architectural split is to avoid having any knowledge about views in the model. In fact, since there can be multiple Diagrams displaying a Model, it wouldn’t be clear what to save and load.

But you can do it if you want. The easiest way to do that is to just call …Model.Save() and modify the returned XElement to add whatever Diagram state you want before you store the XML. And do the opposite upon Load().

Ah, I hadn’t considered the many view to one model case, but that of course makes sense. Thanks for the tip, I’ll give that a go.