Blazor.Diagrams: Nullreference exception when adding link model target/source ports
For some reason the following code throws a NRE Am I doing something wrong?
Diagram.Nodes.Add(current);
if (parent is not null)
{
var link = new LinkModel(parent, current)
{
TargetMarker = LinkMarker.Arrow
};
link.SetSourcePort(parent.GetPort(PortAlignment.Bottom));
link.SetTargetPort(current.GetPort(PortAlignment.Top));
Diagram.Links.Add(link);
}
Stacktrace:
at Blazor.Diagrams.Core.Layers.LinkLayer.OnItemAdded(BaseLinkModel link)
at Blazor.Diagrams.Core.BaseLayer`1.Add(T item)
at ForkHierarchy.Pages.Index.<RenderNodeAsync>d__24.MoveNext()
Checking whether I am adding a null value to SetSource/TargetPort, shows me that they do have values:
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15
Oh! I didn’t know you had to add a PortRenderer to the custom node razor file! 😄 My bad
With this all my questions in this regards were answered. Thanks