Node can't show any style and shape which generate from code behind

Hi,
I trying follow document:
https://help.syncfusion.com/wpf/sfdiagram/node
To use C# code to generated the node, but it seen not working as expect.
It just show the node area.
Please assist, thanks!

Windows 10 1709
Visual Studio 2017 15.5.1
.Net framework 4.7.02556
Syncfusion.SfDiagram.WPF runtime version v4.0.30319 

The code behind:

 public MainWindow()
        {
            InitializeComponent();
            //Creates the Node collection
            ObservableCollection nodes = new ObservableCollection();

            Style style = new Style(typeof(Path));
            style.Setters.Add(new Setter(Path.FillProperty, Brushes.DarkCyan));
            style.Setters.Add(new Setter(Path.StrokeProperty, Brushes.Black));
            style.Setters.Add(new Setter(Path.StrokeThicknessProperty, 2d));
            style.Setters.Add(new Setter(Path.StrokeDashArrayProperty, new DoubleCollection() { 5 }));
            style.Setters.Add(new Setter(Path.StretchProperty, Stretch.Fill));

            //Create Node
            NodeViewModel node = new NodeViewModel()
            {
                //Sets the size
                UnitWidth = 100,
                UnitHeight = 100,

                //Sets the position
                OffsetX = 200,
                OffsetY = 200,

                //Customizes the appearance
                Shape = new RectangleGeometry() { Rect = new Rect(0, 0, 10, 10) },
                ShapeStyle = style
            };

            //Adds the Node to the SfDiagram              
            nodes.Add(node);
            diagram.Nodes = nodes;
        }

xaml:
   
   
       
       

            
       
   


3 Replies

JS Jayanthi Sivabalan Syncfusion Team December 19, 2017 10:24 AM UTC

Hi Nathaniel, 
 
It looks like the properties of your NodeViewModel is not applied/binded to the Node (view). Please define the binding style for Node as shown in the following code example. 
 
Code example: 
<ResourceDictionary> 
    <ResourceDictionary.MergedDictionaries> 
        <ResourceDictionary Source="/Syncfusion.SfDiagram.Wpf;component/Resources/BindingStyle.xaml" /> 
    </ResourceDictionary.MergedDictionaries> 
     
    <!--Initialize node binding style--> 
    <Style TargetType="syncfusion:Node" BasedOn="{StaticResource NodeBindingStyle}"> 
    </Style> 
</ResourceDictionary> 
 
 
For more information, please refer the online documentation link as below location. 
 
 
Regards, 
Jayanthi S. 
 



NC Nathaniel Chen December 19, 2017 10:49 AM UTC

Yeah, It working.

Appreciate your help!


JS Jayanthi Sivabalan Syncfusion Team December 20, 2017 03:43 AM UTC

Hi Nathaniel, 
 
Thanks for the update. 
 
Regards, 
Jayanthi S. 


Loader.
Up arrow icon