Diagram Node's content template will not be copied with node

I use the ContentTemplate to draw nodes, when I use CTRL+C or context menu to copy the node, the effect specified by the ContentTemplate don't appear on the copied node, the setted port constraint  Hitpading don't appear on the copild node too.



1 Reply 1 reply marked as answer

DT Deepa Thiruppathy Syncfusion Team February 22, 2022 02:07 PM UTC

Hi Tealer, 
 
 
Requirement:  How to serialize NodeViewModel’s Content, ContentTemplate properties on duplicating it. 
 
   
We have analyzed your requirement. And since we do not serialize the content property by default, it can be achieved by deriving custom class for NodeViewModel. At the derived class, you can add a property to store the value of NodeViewModel ‘s Content or ContentTemplate property using ItemAddedEvent. And to serialize a new datatype, we need to add the new type in SfDiagram's KnownTypes. Port constraints, HitPadding will be working, once node is getting serialized properly. 
  
We have prepared simple sample for the same as below,  
 
 
Please find below ug documentation links for serializing a custom class:  
 
 
 
 
Regards, 
 
Deepa Thiruppathy 


Marked as answer
Loader.
Up arrow icon