Referring to http://es.infragistics.com/samples/wpf/diagram/binding-nodes-with-objects
Can you please suggest recommended way of aligning new nodes if a child node is created on fly. I have set TreeDiagramLayout's NodeFlowDirection to "Below" but when a new object is added in viewmodel at run time it goes to top left corner of diagram.
Ideally starting from parent, I would like nodes to be center aligned and newly created to be below parent node.
Ok, thank you for the suggestion.
Hello Abs,
Thank you for following up. This again is related to the time it takes to load the nodes and the layout. Please wrap the RefreshLayout method inside an asyncronyons Dispatcher.BeginInvoke method:
eg.
private void Items_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { MainWindowViewModel vm = this.EmployesDiagram.DataContext as MainWindowViewModel;
if (e.NewStartingIndex >= vm.Employees.Count) { Dispatcher.Invoke(async () => { this.EmployesDiagram.RefreshLayout(); }); } }
Let me know if you have any questions.
You can use the same code you attached and select any leaf node and then add a new node, it raises an exception.
Is this still an issue? Please provide some code snippet in the CollectionChanged event and I will take a look.
Thanks for coming back to me, I had the same code and exception is raised when a node is added to the leaf node.