Diagram.SelectionCopied problem

Hi!
I am using the event “Diagram.SelectionCopied” to create a new node but unexpectedly were created two new nodes instead of one. I’m using the same method that i use to create the nodes initially (without drag and paste). Can someone help me please with this issue? Thanks

I found a solution by made override of paste command. The code is below (i hope that this can help someone):


public class MainApp : Window
{


<span =“Apple-tab-span” style=“white-space:pre”> …


<span =“Apple-tab-span” style=“white-space:pre”> public MainApp ()
{
<span =“Apple-tab-span” style=“white-space:pre”> …
<span =“Apple-tab-span” style=“white-space:pre”>
<span =“Apple-tab-span” style=“white-space:pre”> myDiagram.CommandHandler = new myDiagram_CommandHandler(this);


<span =“Apple-tab-span” style=“white-space:pre”> …


<span =“Apple-tab-span” style=“white-space:pre”> }

<span =“Apple-tab-span” style=“white-space:pre”> ///


/// Custom command handlers
///

class myDiagram_CommandHandler : CommandHandler
{
private MainApp _receiver;


public myDiagram_CommandHandler(object receiver)
{
_receiver = receiver as MainApp;
}


public override void Paste()
{
//base.Paste();


if (_receiver.currentNode == null) return;


Point currentMousePosition = _receiver.myDiagram.LastMousePointInModel;


<span =“Apple-tab-span” style=“white-space:pre”> //Gets the mouse position on diagram
Point pastedObjectPosition = new Point(currentMousePosition.X - (_receiver.currentNode.ActualWidth / 2), currentMousePosition.Y - (_receiver.currentNode.ActualHeight / 2));


_receiver.currentNode = _receiver.CreateNode(_receiver.currentNode.Category.ToString(), pastedObjectPosition);


_receiver.currentNode.IsSelected = true;
}
}







}