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

Dropping Custom Node to SfDiagram from Stencil

Good day!
I try to use SfDiagram at Essential Studio for WPF v.14.3.0.52 I want to combine two of your samples: "Stencil" and "Node Content".
I need put custom nodes( like "Node Content") from Stancil. I had some difficulty with that.
i can programmatically create and put Node object, but I cant do it correctly with NodeViewModel object. 
If you have any tips, please let me know.

I attached my project as example.

Thanks!

Attachment: Editor_cc09cfd7.7z

3 Replies

KR Keerthivasan Ramamoorthy Syncfusion Team November 9, 2016 01:09 PM UTC

Hi Dmytro, 
 
We have deprecated the default View to ViewModel binding for Node and Connector. So, The properties of NodeViewModel and ConnectorViewModel will be bind to Node and Connector once Style is created in application(For Node and connector) with Default style key from BindingStyle.Xaml. We have to set BindingStyle while using ViewModel. We have modified the provided sample with these changes. 
Please refer to the modified sample from the below link. 
 
Sample link:Editor_Modified
 
 
Regards, 
Keerthivasan R. 



DM Dmytro January 30, 2017 10:21 AM UTC

Hi again!
This video was made from your code example from this topic.
could you help me to find the reason why my elements have this behavior.
Thanks!

Attachment: Video_20170112_113813_65fce241.7z


SS Suresh Shanmugam Syncfusion Team January 31, 2017 10:20 AM UTC

Hi Dmytro, 
 
Reported Issue: Issue with duplicate the Node with UIElement (Button) 
 
We have used DataContarctSerilaizer to do clipboard action in SfDiagram. We did not serialize the framework properties like Content and ContentTemplate properties. But the reported issue can be resolved in sample by using  ItemAdded Event of SfDiagram. 
 
Please refer the below code snippet how to set the Content and ContentTemplate in ItemAdded Event. 


//ItemAdded Event 
private void MainWindow_ItemAdded(object sender, ItemAddedEventArgs args) 
{ 
       if (args.ItemSource == ItemSource.ClipBoard) 
       { 
              CustomNodeViewModel cnvm = args.Item as CustomNodeViewModel; 
              cnvm.Content = new uButton() { Content = "SomeTEXT", Width = 50, Height = 50, IsEditable = false, ToolTip = "blah-blah-blah-blah" }; 
              cnvm.ContentTemplate = new DataTemplate { VisualTree = new FrameworkElementFactory(typeof(uButtonTemplete)) }; 
       } 
} 


Regards, 
Suresh Shanmugam 


Loader.
Up arrow icon