I have a canvas where a draw some GraphNodes and add them to the canvas as ContentControls. All graph nodes have an adorner which I use to draw connection lines from a node to another node. The adorner has a method OnMouseUp:
protected override void OnMouseUp(System.Windows.Input.MouseButtonEventArgs e)
{
var SourceNode = AdornedElement;
Point pt = PointToScreen(Mouse.GetPosition(this));
var DestinationNode = ???
}
At this point I have the source node from where I started to draw the line in in AdornedElement which is the initial GraphNode. Also, I have the coordinates where the mouse was released. Under this point is another GraphNode. How to find the node that is under this point ?
Thank you.
OK, after many research I have found a solution:
And then the HitTest method to find the GraphNode. Remember that GraphNode is a custom object.