Using connection tool to draw custom connection

4 posts, 0 answers
  1. Paolo
    Paolo avatar
    2 posts
    Member since:
    Jul 2015

    Posted 17 Sep 2015 Link to this post

    Hi,

    I implemented some custom connections, deriving them from RadDiagramConnection. My connections have their own properties and visual aspect (defined using styles). I'd like to use the Telerik connection tool to draw my custom connection: how can i set the custom connection type to the connection tool?

    Thank you in advance

    Paolo

  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 18 Sep 2015 Link to this post

    Hello Paolo,

    In order to force the diagram to use a custom connection object you can override its GetConnectionContainerForItemOverride() method and return the custom connection. Here is an example for this.
    public class CustomDiagram : RadDiagram
    {
        protected override Telerik.Windows.Diagrams.Core.IConnection GetConnectionContainerForItemOverride(object item)
        {
            return new MyCustomConnection();
        }
    }

    Please give this approach a try and let me know if it works for you.

    Regards,
    Martin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Paolo
    Paolo avatar
    2 posts
    Member since:
    Jul 2015

    Posted 21 Sep 2015 in reply to Martin Link to this post

    Thank you Martin,

    the override works fine when drawing a connection after the tool activation by code:

     

    var service = Diagram.ServiceLocator.GetService<IToolService>() as ToolService;
    service.ActivateTool(ConnectionTool.ToolName);​

     

     If I start drawing from a shape connector, the connection tool steals the last drawn connection and the tool redraws the connection from the connector. Maybe I have to restore something else?

    Regards

    Paolo

  5. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 24 Sep 2015 Link to this post

    Hi Paolo,

    I wasn't able to reproduce anything unusual when using the approach from my last reply. This is why I attached a sample project demonstrating this approach. Can you please give it a try and let me know if I am missing something?

    Regards,
    Martin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top