Nodes with different data properties

Hi, all

I want to create a flow chart with several types of nodes, each has different data properties. For example, node type A has properties of a, b, and c, and node type B has properties of x, y, and z. I took it for granted that I can derive several classes (NodeDataA, NodeDataB, …) from GraphLinksModelNodeData, each corresponds to a type of node. But it seems that the GraphLinksModel can only has one kind of NodeType. If the model is created with base NodeType (GraphLinksModelNodeData, from which NodeDataA and NodeDataB are derived), the derived node will not be shown on the diagram.

Are there any alternative methods to achieve my goal? Thanks.

zz

The easiest way is to define a base class inheriting from GraphLinksModelNodeData, and then define your separate data classes inheriting from that.

There is an example of this in the Piping sample, Piping.xaml.cs: the ItemData class and the three classes that inherit from ItemData. Your model would be a GraphLinksModel<ItemData, …>.

Great! Thank you very much!

Dear Walter,

I wrote some codes that even the LinkData has its own properties, so I overrided the MakeXElement and LoadFromXElement method. The extra properties can be written to the xml file, but can not be read out. I always get the default value.

The following is my code and debug result.

What’s wrong with the code? The similar code works well in the NodeData class.

zz

[QUOTE=walter]The easiest way is to define a base class inheriting from GraphLinksModelNodeData, and then define your separate data classes inheriting from that.
There is an example of this in the Piping sample, Piping.xaml.cs: the ItemData class and the three classes that inherit from ItemData. Your model would be a GraphLinksModel<ItemData, …>.

[/quote]

That does seem odd. I am sorry, but I am unable to investigate this at the moment.

But I do have one off-the-wall suggestion: try typing “0.0” instead of “0” as the default value.

EmbarrassedIt’s my fault. For a primitive type, the XHelper.Read method should be used. Thank you.