Rollback Transaction of previous link with modal dialog

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.

Because of this entry: Transaction is being rolled back while showing a MessageBox
I am setting the TransactionResult like this:

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.

How can I solve the problem?

On further investigation I see that there is a difference in the order:

In the linking process where I do not show a modal dialog, I first add the connection view model to the observable collection and then the StopTransaction method is called.

In the linking process where I do show a modal dialog, the StopTransaction method is called before I add the connection view model to the observable collection.

How can I call StopTransaction manually?

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.