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.

Dropping Custom Node to SfDiagram from Stencil

Thread ID:

Created:

Updated:

Platform:

Replies:

127293 Nov 8,2016 06:22 AM Jan 31,2017 05:20 AM WPF 3
loading
Tags: SfDiagram
Dmytro
Asked On November 8, 2016 06:22 AM

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

Keerthivasan Ramamoorthy [Syncfusion]
Replied On November 9, 2016 08:09 AM

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. 


Dmytro
Replied On January 30, 2017 05:21 AM

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

Suresh Shanmugam [Syncfusion]
Replied On January 31, 2017 05:20 AM

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 


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.

;