Create connection between Shapes

2 posts, 0 answers
  1. Christian
    Christian avatar
    7 posts
    Member since:
    Sep 2010

    Posted 03 Aug 2012 Link to this post

    Hi there, I have a diagram where I need to connect two shapes. So I create a Connection between one shape to another, but the target is always null.
    I use the ConnectionManipulationCompleted event and obtain the target from the args e.Connection.Target.

    How can I obtain the target element?
  2. Christian
    Christian avatar
    7 posts
    Member since:
    Sep 2010

    Posted 03 Aug 2012 Link to this post

    Found my own solution here!

    This is the code that I use to solve the Target Problem:
    private void diagram_ConnectionManipulationCompleted(object sender, ManipulationRoutedEventArgs e)
    {
     var connectedShapes = diagram.GetOutgoingConnectionsForShape(e.Shape).Select(c => c.Target);           
     var test = connectedShapes.FirstOrDefault().Content;
     
     e.Connection.Target = connectedShapes.FirstOrDefault();
    }

    Hope it helps.
  3. DevCraft banner
Back to Top