I have the following problem using the custom linking tool. I want a dialog to popup when creating a link with the custom linking tool. On confirmation the link should be created.
The problem is that a rollback is done once the dialog pops up and it removes the previously inserted link.
public override void DoDeactivate()
if (this.targetPortFound == true)
this.TransactionResult = “NewLink”;
So I thought now the transaction is committed.
However if I start a new linking that I drop where there is no end port, a rollback occurs, which is correct so that there is no link without end port, but the problem is that the previous link is also removed.
Investigating this, I see that the transaction is stopped and committed but the new link only is created after I add the connection view model into the observable collection.
Is your dialog truly modal? In other words, when you execute some statement to show the dialog, does it not return until the user has chosen some answer?
If that were the case, everything ought to be working OK.
But that is obviously not the case, so it seems that your dialog is not modal, which means it is acting asynchronously to the events happening in the LinkingTool. So the code in the LinkingTool is finishing normally, without any input from the dialog.
Why not allow the normal behavior of the LinkingTool occur? Afterwards, in a Diagram.LinkDrawn event handler you can show your dialog. If the user chooses not to complete the link, you can delete the Link.
In addition, you can implement link validation in order to prevent the user from drawing links that clearly should not be allowed. Read the section about “Link Validation” in the GoXamIntro.pdf.