WPF Diagrams: New tree layout algorithm

In the latest nightly build of WPF Diagrams is a new layout algorithm for displaying tree like structures. The TreeLayoutAlgorithm is much smarter than the existing layout algorithm when it comes to positioning the nodes, handling cycles and managing nodes that have multiple parents. It also makes it easy for you to customize the vertical and horizontal spacings between nodes, using the LayerSpacing and NodeSpacing properties. Here is an example of a diagram being managed by a TreeLayoutAlgorithm and using an A* pathfinder for routing the connections.

WPF Diagrams Tree layout algorithm

Using a layout algorithm is incredibly simple. All you need to do is create an instance of the layout algorithm of choice, then pass it into the ApplyLayoutAlgorithm method on the DiagramSurface.

ILayoutAlgorithm layout = new TreeLayoutAlgorithm();
ds.ApplyLayoutAlgorithm(layout);

If you need a tree based layout for your diagramming application, then download the latest nightly builds and you’ll be pleased with the results. If you have any questions about WPF Diagrams, then we would love to hear from you in our forum.

Tagged as WPF Diagrams

Leave a Reply

Archives

Join our mailer

You should join our newsletter! Sent monthly:

Back to Top