Hi,
Im using TreeLayout to Layout a diagram with few nodes.
but,
I am having problems with having scrollviewer & aligning the tree to the center of the diagram
1.using scrollviewer is only showing the vertical scrollbar, horizontal scrollbar is not being shown
2.how do i align the tree to the center of the diagram?
(or)
make the root node to the center(so that its position can be kept the same in the TreeLayout, thereby making the tree still centered?
I have programmatically set the Bounds for the rootNode(such that it appears center) and set the TreeLayout.KeepRootPosition to true, but still, after the no of items increase - the horizontal scrollbar doesnt appear and the root node keeps shifting
here's the xaml file and code behind :
<Grid x:Name="LayoutRoot" Background="White">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<mindfusion:Diagram x:Name="diagram" Loaded="diagramm_Loaded"></mindfusion:Diagram>
</ScrollViewer>
</Grid>
private ShapeNode rootNode;
private TreeLayout treeLayout;
public MainPage()
{
InitializeComponent();
}
private void diagramm_Loaded(object sender, RoutedEventArgs e)
{
this.rootNode = new ShapeNode(this.diagram);
this.rootNode.Bounds = new Rect(new Point(this.diagram.Bounds.Width / 2 - this.rootNode.Bounds.Width / 2, this.rootNode.Bounds.Y), new Size(this.rootNode.Bounds.Width, this.rootNode.Bounds.Height));
this.diagram.Nodes.Add(this.rootNode);
//// add 12 children nodes under the root node
ShapeNode child;
for (int i = 0; i < 12; i++)
{
child = new ShapeNode(this.rootNode);
this.AddChild(this.rootNode, child);
}
//if (this.treeLayout == null)
{
this.treeLayout = new TreeLayout(this.rootNode, TreeLayoutType.Centered, false, TreeLayoutLinkType.Straight, TreeLayoutDirections.TopToBottom, 100, 100, true, new Size(0, 0), true);
}
treeLayout.Arrange(this.diagram);
}
private void AddChild(DiagramNode parent, DiagramNode child)
{
this.diagram.Nodes.Add(child);
DiagramLink link = new DiagramLink(this.diagram, parent, child);
this.diagram.Links.Add(link);
}
Could someone help me with this?
Thank you,
Nagarjuna