Limit connections between shapes

2 posts, 0 answers
  1. Mark
    Mark avatar
    2 posts
    Member since:
    Aug 2014

    Posted 10 Feb 2015 Link to this post

    Is there a way to limit which shapes can be connected? 

    For example, my diagram has three shapes, Ellipse, Hexagon and Star. Ellipse can be connected to Star and Hexagon can be connected to Star; however, Ellipse can never be connected to a Hexagon.

  2. Milena
    Admin
    Milena avatar
    201 posts

    Posted 12 Feb 2015 Link to this post

    Hi Mark, 

    You can use RadDiagram.ConnectionManipulationCompleted event to achieve your requirements. In the arguments of that event you will be able to access all the information that you need to decide if the connection should be attached to the target or not. If you handle this event the connection will not be generated. In your case you can check the shape geometry and handle the event when the shapes are Ellipse and Hexagon. You should only have in mind that depending on the action the target or the source of the connection could be not set yet and then you can use e.Shape from the event argument which represents the new value (e.g. if you change the target the e.Shape will provide information about the target, if you change the source - for the source). 
    For your convenience I implemented this approach in the attached project. Please take a look at it and let us know if it works for you.

    Regards,
    Milena
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top