Insert Link operation with LayeredDigraphLayout

Hi Walter,<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I am using a graph with following layout option.

<go:Diagram.Layout>

<golayout:LayeredDigraphLayout LayerSpacing="150" />

</go:Diagram.Layout>

Now I am trying to add the create new link functionality with the control. I want user should be able to link two nodes using built in linking functionality.

To enable the linking functionality I have set following properties to node template

go:Node.LinkableFrom="True" and go:Node.LinkableTo="True"

This has enabled linking feature but after enabling the linking feature I am phasing following problems:

1. User cannot relocate the node using drag and drop. Each time I try to do so it starts new link arrow.

I found that it is possible to relocate the node. I have checked that in the online samples under “Update Demo”. But the only difference in my code is I am using LayeredDigraphLayout. Is there any restriction for this?

2. Automatic layout update after i create a new link between nodes. Because of rearrangement of nodes it is difficult to find the old node in the updated layout when I have lot of nodes in the graph.

Can I cancel the automatic rearrangement of the nodes after I create new link?

Could you please help me solving this problems?
Thanks and Regards,

Hardik

It sounds like your node DataTemplate is using the whole node as a “port”.

By making it possible for the user to start drawing a new link from or to the port, it means that the user can start drawing from any point in the port.
That would mean the user could start drawing a new link from any point in the node.

One possibility is to have a particular FrameworkElement in your node’s visual tree act as the port.
That would mean setting go:Node.PortId as well as go:Node.LinkableFrom and go:Node.LinkableTo on that FrameworkElement.

Another possibility, which might be easier in this circumstance, would be to declare particular FrameworkElements in your node’s visual tree not to act as part of the port.

Those LinkableFrom and LinkableTo attached property “True” values are effectively inherited by all of the FrameworkElements in your node. You can explicitly set those attached properties to “False” on some or almost all of the children of your node. Some of the samples demonstrate this.

Hello Walter,

Thanks a lot for reply.
With your answer I was able to fix my first issue.
Could you please check my second issue too?

2. Automatic layout update after i create a new link between nodes. Because of rearrangement of nodes it is difficult to find the old node in the updated layout when I have lot of nodes in the graph.

Can I cancel the automatic rearrangement of the nodes after I create new link?<?: PREFIX = O />
Is cancelation of automatic rearrangement of links and nodes is possible with LayeredDigraphLayout?
Regards,
Hardik

Sorry about that – I got interrupted while replying and forgot about the second issue.

That’s easy. The conditions under which a layout is invalidated are declared in the DiagramLayout.Conditions property. The default includes the following LayoutChange enumeration flag values:

  • LinkAdded, LinkRemoved
  • NodeAdded, NodeRemoved
  • MemberAdded, MemberRemoved
  • DiagramLayoutChanged, GroupLayoutChanged (i.e. the Diagram.Layout or Group.Layout value has been replaced)

You might want to set the layout Conditions=“None”.

Hello Walter,

I am able to manage my requirement with your suggestion.
Thanks a lot for your support.
Regards,
Hardik