Saving node using MVVM

Hi Walter,

Currently I have a model of my node as follows that is part of a datamodel holding the nodes
public class LatNodeModel : GraphLinksModelNodeData<string>, ILatWorkspaceModel { public Color BackgroundColor { get { return _backgroundColor; } set { var old = _backgroundColor; _backgroundColor = value; RaisePropertyChanged("BackgroundColor", old, value); } } }
}
public class LatDataModel : GraphLinksModel<LatNodeModel, string, string, LatLinkModel>, INotifyPropertyChanged { NodeSource= new ObservableCollection<LatNodeModel>();
}
When I do a save using:
LatDataModel model = ViewModel.LatDataModel; if (model == null) return; XElement root = model.Save<LatNodeModel, LatLinkModel>("LinkAnalysis", "MyNodeData", "MyLinkData");
It saves the key and location of each node, but not the background color of each node. Is there a strategy for saving other View Model information into xml that is contained in the node?

(I moved this post from the GoDiagram forum.)

You need to override the MakeXElement and LoadFromXElement methods. The documentation for GraphLinksModelNodeData and for those two methods gives examples. And there are lots of examples in the sample apps too.

This strategy gives you control over what to save/load, and how to do so.

sorry, posted in the wrong forum accidently

That’s OK – we changed the order that we list the forums, so we expected some confusion.