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.
Unfortunately, activation email could not send to your email. Please try again.

Need help with Custom NodeViewModel

Thread ID:

Created:

Updated:

Platform:

Replies:

130350 May 8,2017 09:29 AM May 16,2017 06:17 AM WPF 6
loading
Tags: SfDiagram
Deepak
Asked On May 8, 2017 09:29 AM

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.

Saranya Chandrasekaran [Syncfusion]
Replied On May 10, 2017 08:36 AM

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. 


Deepak
Replied On May 10, 2017 09:00 AM

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

Deepak
Replied On May 11, 2017 09:29 AM

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

Saranya Chandrasekaran [Syncfusion]
Replied On May 13, 2017 12:22 AM

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. 


Saranya Chandrasekaran [Syncfusion]
Replied On May 13, 2017 12:57 AM

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. 


Saranya Chandrasekaran [Syncfusion]
Replied On May 16, 2017 06:17 AM

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. 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;