We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Put UserControl fom Stencil to SfDiagram

I tryng to add WPF UserControl element to SfDiagram from Stencil. 
For that, I placed to stancil object with ISymbol interface.

at Symbol param, i put uTest class, wich contains parameters for my UserControl object.
at SymbolTemplate contain UserControl object with binding to uTest class.
After that i can put object from stancil to diagram, but can`t copy it, or see it after save/load operation.

How can i do it correctly?
I attached my test programm, based in Flow Diagram example from Essential Studio.

Attachment: Stencil_7b19aa71.zip

7 Replies

DM Dmytro February 24, 2016 09:06 AM UTC

I understand, that for realisation of my idea i need to copy Content parameter from CustomNode parent to its clone. but i can`t understand at what time i need to do this?

RA Ranjitha Amirthalingam Syncfusion Team February 24, 2016 01:38 PM UTC

Hi Dmytro,

Thanks for contacting Syncfusion Support.

Requirement: To duplicate/Serialize the UserControl (Content of Node).

We have used DataContractSerializer for Serialization support and Duplicate operation is based on Serialization. So, The FrameWorkElements did not serialized as per DataContractSerializer Limitation. This causes the reported issue in your application. We have a support to achieve your requirement by using derived NodeViewModel and Property Changed. The Symbol and SymbolTemplate of Symbol will be assigned to Content and ContentTemplate when Dropping from Stencil.

Could you please confirm is your requirement to duplicate/Serialize the UserControl (Content of Node)?

FlowDiagram Sample:
In this Sample, We have updated the Diagramming objects while the respective Collection is Changed.  So, the Duplicate operation is working as expected.

Ranjitha A.

DM Dmytro February 24, 2016 02:06 PM UTC

Thank you for answer. 
Yes this is exactly what i need,  duplicate/Serialize the UserControl (Content of Node).

DM Dmytro March 2, 2016 09:41 AM UTC

Hello! I solve this problem, but i still think that my way is not optimal:
After dropping element from stencil i save all diagram to stream whith its custom filds(Customnode.Content in my case), after that i load  it back. 
After this manipulations i can  duplicate/Serialize CustomNode whith Usercontrol in its Content field.
Anybody know more elegant way to solve my problem? 

RT Ramya Thirugnanam Syncfusion Team March 3, 2016 11:30 AM UTC

Hi Dmytro,
Sorry for the inconvenience caused.
With Regards to “Duplicate/Serialize the UserControl (Content and ContentTemplate of Node)”, we have created a simple sample with proper comments to achieve your requirement. Please refer to the sample from the following link.
Sample Link:123174

Sample Details:
In this Sample, We have used Custom NodeViewModel class to get the notification of Content and ContentTemplate property changes when drag and drop the symbol from Stencil. In that CustomNodeViewModel class, we have used custom properties to store and assign (after Serialization and Duplication) the value of Content and ContentTemplate of NodeViewModel.

DM Dmytro March 10, 2016 09:31 AM UTC

Thanks for your answer , it very helped me. but i still have some question: 
When i drop my custom object to Stancil, it's ok (thanks to your example). 
If i want to copy a few objects from CustomNode instrument, i need  to reshape them, in other way it gives back to me something with zero shape.

RA Ranjitha Amirthalingam Syncfusion Team March 11, 2016 12:27 PM UTC

Hi Dmytro,

We have considered this requirement “Notify when diagramming object is duplicated with source” as a feature request and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.



Ranjitha A.

Live Chat Icon For mobile
Up arrow icon