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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Diagram in code. Nodes laying on top of each other.

Thread ID:





104322 Jul 11,2012 12:28 AM UTC Jul 18,2012 01:06 PM UTC WPF 3
Tags: Diagram
Alan Churchill
Asked On July 11, 2012 12:28 AM UTC

I have a bit of code that attempts to create a digram completely in code-behind. It works fine if I do a Show() on the window before adding the nodes. However, if I add the nodes first, then doa  show, all of the nodes are stacked on top of each other. I assume that the layout is being constrained somehow until I submit a Show command. Can you tell me how to build a diagram 100% in code behind?
Code below:
        public void Process(SasLog log)
           // this.Show();  <---- WORKS FINE.
            int y = 0;
            int x = 0;
            foreach (var fe in log.FlowElements)
                var rect = CreateNode(x, y, fe);
                x = fe.Level * 150;
                y += 100;
            this.Show();   <-- DOES NOT SHOW DIAGRAM CORRECTLY
        //Creating the Node
        private Node CreateNode(double x, double y, FlowElement fe)
            Node n = new Node();
            //Custom Label property to the Node
            n.LabelTextWrapping = TextWrapping.Wrap;
            n.LabelFontWeight = FontWeights.Light;
            n.LabelVerticalAlignment = VerticalAlignment.Top;
            n.LabelHorizontalAlignment = HorizontalAlignment.Left;
            n.Label = DetermineLabel(fe);
            n.LabelForeground = Brushes.White;
            n.LabelDisplacement = new Point(10, 20);
            n.Width = 150;
            n.Height = 75;
            n.OffsetX = x;
            n.OffsetY = y;
            return n;

Ramya Thirugnanam [Syncfusion]
Replied On July 13, 2012 04:10 AM UTC

Hi Alan,

Thanks for using Syncfusion Products and we regret for the inconvenience caused.

We have analyzed the reported issue and we are unable to reproduce the issue with the given information.

Can you please revert us with a sample based on your application along with the replication procedure to reproduce this issue? This would be helpful for us to serve you better.

Also, please let us know if you would require any assistance on this.

Alan Churchill
Replied On July 13, 2012 06:36 PM UTC

See attached project. 2 methods. One labeled as Works and 1 labeled as DoesNotWork.


Ramya Thirugnanam [Syncfusion]
Replied On July 18, 2012 01:06 PM UTC

Hi Alan,

We have analyzed your query, we are able to reproduce the reported problem.it is by design; the DirectedTreeLayout does not arranges the Nodes which are in disconnected (not connected) state. This is the cause of your problem(node placed on each other).

Details about Directed-Tree layout:

The Directed-Tree layout arranges the nodes in a tree-like structure. This layout can be applied to any diagram that comprises a directed tree graph with unique root and child nodes. This makes creating diagrams easier because the node position is determined automatically, based on the connections. However, it is necessary to specify a layout root for the tree layout. The Directed-Tree layout will position the nodes based on the layout root.

We assumed that your requirement is to arrange the Nodes in vertical manner, then please use TableLayout to achieve your requirement,

If this response does not satisfy your requirement, please provide us more details about your requirement. This would help us to serve you better.

Please let us know if you have any concerns.


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon