How not to start a Link

I need to make a check that if a (Bar) node is within a Group (Property->Text with Value->"A" on GraphLinksMadelNodeData) then user can not start a link from this (Bar) node (can still link to it) but if a (Bar) node (based on same template) is inside a different Group (Property->Text with Value->"B" on GraphLinksMadelNodeData) then it can be linked to and from.

It is too late for LinkingTool's IsValidLink method because link has already started and I want that user should not even be able to start a link

I can not get the actual From node in LinkingTool's Canstart override and hence cannot check (Bar) node's ContaingSubgraph's Text property and return false to stop the operation

I know it can be achieved by setting [Code]go:Node.LinkableFrom="False"[/Code] on the (Bar) node but how and where do I do it as this value is dependant on a value of the ContaingSubGraph

what is the best way to do this?

I suppose you could use data-binding for the value of go:Node.LinkableFrom, but you’d need to write some code anyway, so you might as well customize the Diagram.LinkingTool by overriding its IsValidFrom and/or IsValidTo methods.

Those two predicates get called during the process of finding legitimate ports at which links may be started, in the FindLinkablePort method, which is called by CanStart.

Thanks Walter, IsValidFrom works.
I did not try it in the first place thinking it will work just like IsValidLink and will let you start the link but not terminate it but obviously that is not the case with IsValidFrom and IsValidTo.