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

ItemAdded for DragDrop Not Firing

I have mocked up a quick example based on various part projects I've seen on the forum, but I've merged it with the my data objects (simplified versions) I have in my main project. I have two problems, which I think are related.

1) When I add an item to the diagram through adding a new object into my collection: the object is added and appears on the diagram canvas, but can't be interacted with

2) When I drag from the stencil there is no trigger of the "ItemAdded" event I've seen in the examples

I've uploaded the example and your help would be appreciated.

Attachment: sfDiagramTest_26747ee8.7z

5 Replies

RT Ramya Thirugnanam Syncfusion Team April 11, 2019 05:25 AM

Hi Mike, 
Thanks for contacting Syncfusion support. 
We have modified the sample to resolve the reported issue. Please find the modified sample as below. 
Reported issue 
When I add an item to the diagram through adding a new object into my collection: the object is added and appears on the diagram canvas but can't be interacted with. 
We can reproduce the reported issue. The root cause of the reported issue is implementing the INotifyPropertyChanged for the UIControl class. It restricts the property changed notifications of  its base class “NodeViewModel” . So, the interaction with node is dis abled.  
Please remove the INotifyProperyChanged from the UIControl class. 
public class UIControl : NodeViewModel/*, INotifyPropertyChanged*/ 
Additional Information Required: 
Could you please confirm us whether your requirement is to implement custom property changed notification in UIControl? 
When I drag from the stencil there is no trigger of the "ItemAdded" event I've seen in the examples 
We can reproduce this reported issue. This is the sample side issue.  Please don’t use or set  NodeViewModel as content of the Symbol/NodeViewModel. Since, we are using serialization and deserialization approach for drag and drop the element from stencil. 
We can host the NodeViewModel as symbol instead of ISymbol to the stencil. Based on that , we have modified the sample.  
Sample Changes: 
We have created a custom class named as UIControlContent and assigned this as content of the NodeViewModel. 
Also, Content and ContentTemplate cannot be serialized while drag and drop. So, we have achieved this(content) by using custom property ContentName and initialized the ContentTemplate in the ItemAddedEvent. 
We have set UnitWidth and UnitHeight for UIControl in its constructor. 
Additional Information: 
We need to add DataContract and DataMember attributes for new serializable custom class and its properties.  
Ramya T 

MC Mike Cowing April 11, 2019 07:57 PM

Thank you for the quick response.

To confirm your UIControl question. I do need property changed notification, but I'm happy with the intermediate ViewModel class approach. I understand how that's working, so I'm ok with that. 

I've taken a look and whilst I can get the example to work, when I integrate this into my main code it fails to work. I suspect it's the same INotifyProperyChanged issue, but I can't track down how this is interfering. It appears to me as though the code for the class is correct, and as per the example. I've even created a simple version of my class, which is identical and still no dice.

What I'm experiencing is when I drag from the stencil, I don't see any preview, nor do I trigger the ItemAdded event. As I understand it the ItemAdded event will take a serialized copy of the stencil object. The ContentTemplate is essentially what's visualised as part of drag/drop and the display on the diagram. Incidentally if I add this code to the example "stencil.Constraints = StencilConstraints.ShowPreview | StencilConstraints.GroupExpanded;" this doesn't trigger the ItemAdded event either and is similar to the behaviour I see in my app. Is that related? and why would that code not work. It's using bitwise to configure the Constraints?

I'm happy to send you my main application if that'll help, but I don't want to post it publically. Is there any check I can do to see if INotifyProperyChanged is getting in the way?

Thanks, Mike...

RT Ramya Thirugnanam Syncfusion Team April 12, 2019 07:32 AM

Hi Mike, 
In order to work with your main application, a support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates .  
Ramya T  

MC Mike Cowing April 12, 2019 04:23 PM

I'll respond on the ticket too, but I've recreated the UserControl from scratch and I have it working correctly now. I am not sure why it's working, or rather why it wasn't as the code looks identical. 

Thanks for your help...

KR Karkuvel Rajan Shanmugavel Syncfusion Team April 15, 2019 06:44 AM

Hi Mike, 
Thanks for the update.  
Please let us know if you require further assistance on this. 
Karkuvel Rajan S 

Live Chat Icon For mobile
Up arrow icon