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

Need help with Custom NodeViewModel

Hi,

We are creating custom NodeViewModel with custom properties in it for symbols. We will be creating many (like 100, 200) such custom symbols with custom NodeViewModel. Is there a way I can find which symbol has been dropped on the SFDiagram from Stencil?

I had look at following link where you suggested using custom NodeViewModel. Could you please provide sample where we have multiple NodeViewModels?
https://www.syncfusion.com/forums/124686/get-symbolitem-from-sfdiagram

Looking forward to your response.

Thanks.
Deepak.

6 Replies

SC Saranya Chandrasekaran Syncfusion Team May 10, 2017 12:36 PM UTC

Hi Deepak, 
 
Requirement: 
Is there a way I can find which symbol has been dropped on the SFDiagram from Stencil? 
 
Response: 
 
Instead of searching which symbol is dropped into SfDiagram, we can directly add symbols into NodeViewModel. Please refer to our Dashboard Sample Stencil Demo using the following navigation link  
 
Navigation Link: Essential Studio->Desktop->WPF->Run Offline->Diagram->Getting Started -> Stencil  
 
Sample Details:  
  
In this sample, we added the NodeViewModel to the SymbolCollection. 
 
Regards, 
Saranya C. 



DE Deepak replied to Saranya Chandrasekaran May 10, 2017 01:00 PM UTC

Hi Deepak, 
 
Requirement: 
Is there a way I can find which symbol has been dropped on the SFDiagram from Stencil? 
 
Response: 
 
Instead of searching which symbol is dropped into SfDiagram, we can directly add symbols into NodeViewModel. Please refer to our Dashboard Sample Stencil Demo using the following navigation link  
 
Navigation Link: Essential Studio->Desktop->WPF->Run Offline->Diagram->Getting Started -> Stencil  
 
Sample Details:  
  
In this sample, we added the NodeViewModel to the SymbolCollection. 
 
Regards, 
Saranya C. 


Hi Saranya,

Thank you very much for you answer.

We did same. We have many custom NodeViewModel classes which inherits SyncFusion's NodeViewModel class. But symbol collection is created as a collection of NodeViewModel class.

When symbol is dropped on the diagram, following method is called in which I have to create instance of the specific NodeViewModel class associated with Symbol.
protected override object GetNewNode(Type desiredType)

Parameter "desiredType" gives me type as "NodeViewModel" and NOT our specific NVM, we are stuck.

Please help us to create specific NVM instance based on symbol dropped from Stencil.

Thanks.
Deepak


DE Deepak May 11, 2017 01:29 PM UTC

Additional notes:

Stensil uses SymbolCollection. SymbolCollection is list of NodeViewModel instances. We have added our custom NodeViewModel class instance into SymbolCollection and attached random shape to symbol.

Now when we drop this custom symbol into diagram, we want to create instance of our Custom NodeViewModel class and return the same into NodeCollection. This is because when we will save diagram, it will serialize our custom properties.

But currently when we drop our custom symbol, we are unable to create instance as we don't know which symbol was dropped. We have overridden below method and this method should tell us which instance should be created:
protected override object GetNewNode(Type desiredType)

But desiredType is always of NodeViewModel type. It should be of Custom NodeViewMolde type when our custom symbol will be dropped into the diagram.

Could you please help us in this regard? Or this is how SFDiagram and Stencil supposed to work? Should we consider this as bug from our point of view?

Thanks and regards,
Deepak


SC Saranya Chandrasekaran Syncfusion Team May 13, 2017 04:22 AM UTC

Hi Deepak, 
 
Currently, we have created the “NodeViewModel” when drop the Symbol based on the type Nodes Collection property of the Diagram. We don’t have support to achieve/customize the desired type of the Node while drag and drop. 
We have already logged your requirement “Customize the desired type of the Node while drag and drop from Stencil” in our database. We will implement this and it will be available in any of our upcoming Volume releases.  
 
Regards, 
Saranya C. 



SC Saranya Chandrasekaran Syncfusion Team May 13, 2017 04:57 AM UTC

Hi Deepak, 
 
The desiredType of GetNewNode method is assigned based on type of Collection is used for SfDiagram.Nodes. If it is of type ObservableCollection<NodeViewModel> then NodeViewModel will be the desired type. If you use ObservableCollection<CustomNode> then we will get CustomNode as the desired type. 
 
However, currently we do not consider desired type based on the what type of item is dropped from stencil. We will consider this requirement as enhancement. We will provide an estimate for this usability feature on Monday 15th May. 
 
Regards, 
Saranya C. 



SC Saranya Chandrasekaran Syncfusion Team May 16, 2017 10:17 AM UTC

Hi Deepak, 
 
We have considered your requirement “Customize the desired type of the Node while drag and drop from Stencil” as an enhancement and a support incident has been created under your account to track the status of this. Please log on to our support website to check for further updates. 
 
 
Regards, 
Saranya C. 
 


Loader.
Up arrow icon