directed tree layout and deleting nodes

I have an application where I build a directed tree.
In this application, I need to be able to clear all nodes and rebuild a new directed tree layout.

I do this:

diagramModel.Nodes.Clear();
diagramModel.Connections.Clear();

MyRebuildTree(); //this also sets a new diagramModel.LayoutRoot node


DirectedTreeLayout tree = new DirectedTreeLayout(diagramModel, diagramView);
tree.RefreshLayout();

I also tried this:


DirectedTreeLayout tree = new DirectedTreeLayout(diagramModel, diagramView);
tree.PrepareActivity(tree);
tree.StartNodeArrangement();
tree.RefreshLayout();
(diagramView.Page as DiagramPage).InvalidateMeasure();
(diagramView.Page as DiagramPage).InvalidateArrange();


The problem I am having is the diagram model's nodes are not being removed/cleared.
When the tree is redrawn the old nodes appear stacked in one corner of the display.

How do you remove nodes/connections from the diagram model?

Thanks in advance,
Mary




1 Reply

MA Maria Amal Raj T Syncfusion Team April 8, 2011 11:37 AM UTC

Hi Mary,

After creating new nodes please update the layout before updating RefreshLayout() as shown in the following code snippet.

Code Snippet :

diagramModel.Nodes.Clear();
diagramModel.Connections.Clear();
MyRebuildTree();
//Update the page layout
diagramView.Page.UpdateLayout();
DirectedTreeLayout tree = new DirectedTreeLayout(diagramModel , diagramView);
tree.RefreshLatout();

Please let us know if you have any further queries.

Regards,
Maria Amal Raj T,
Diagram WPF & Silverlight Team,
[Syncfusion].


Loader.
Up arrow icon