How to update the nodes one after another in the container while dropping in UWP Diagram?
In our UWP Diagram, You can update the nodes sequentially in the Container while dropping, using the ItemDrop event. In this event, update the offset of each node based on the position of the last node in the container.We have provided the code example for how to achieve this. Please refer to the code example
Code Snippet
(Diagram.Info as IGraphInfo).ItemDropEvent += MainPage_ItemDropEvent;
private void MainPage_ItemDropEvent(object sender, ItemDropEventArgs args)
{
IEnumerable<object> target = args.Target as IEnumerable<object>;
if(target != null)
{
foreach(object item in target)
{
if(item is ContainerViewModel)
{
if((item as ContainerViewModel).ID.ToString() == "Horizontal")
{
NodeViewModel node = args.Source as NodeViewModel;
ContainerViewModel container = item as ContainerViewModel;
if(container.Nodes != null && (container.Nodes as NodeCollection).Count == 0)
{
node.OffsetX = container.OffsetX;
node.OffsetY = container.OffsetY;
}
else if(container.Nodes != null)
{
node.OffsetY = container.OffsetY;
node.OffsetX = (container.Nodes as NodeCollection).Last().OffsetX + 50;
}
}
if ((item as ContainerViewModel).ID.ToString() == "Vertical")
{
NodeViewModel node = args.Source as NodeViewModel;
ContainerViewModel container = item as ContainerViewModel;
if (container.Nodes != null && (container.Nodes as NodeCollection).Count == 0)
{
node.OffsetX = container.OffsetX;
node.OffsetY = container.OffsetY;
}
else if (container.Nodes != null)
{
node.OffsetX = container.OffsetX;
node.OffsetY = (container.Nodes as NodeCollection).Last().OffsetY + 50;
}
}
}
}
}
}
Conclusion:
I hope you enjoyed learning How to update the nodes one after another in the container while dropping in UWP Diagram
Refer to our UWP Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, try our 30-day free trial to check out our other controls.
Please let us know in the following comments section if you have any queries or require clarifications. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!