I'm trying to create a program that connects two objects. When MouseDown
on the first object, I remember it (without releasing the mouse button), when I MouseUp
on the second object, I want to create a connection between them, but when MouseUp
on the second object, this event is triggered on the first object.
private void myThumb1_MouseDown(object sender, MouseButtonEventArgs e)
{
inherObj1 = mt;
connector = new Line
{
X1 = e.GetPosition(myCanvas).X,
Y1 = e.GetPosition(myCanvas).Y,
X2 = e.GetPosition(myCanvas).X,
Y2 = e.GetPosition(myCanvas).Y,
Stroke=Brushes.Black
};
myCanvas.Children.Add(connector);
}
private void myThumb1_MouseUp(object sender, MouseButtonEventArgs e)
{
MyThumb mt = sender as MyThumb;
if(isInher)
{
inherObj2 = mt;
CreateInher(inherObj1, inherObj2);
}
e.Handled = true;
}
As I understand it, the MouseUp
is attached to the object on which MouseDown
worked. Is there any way around this?