Custom connection and MVVM

5 posts, 1 answers
  1. Sarper
    Sarper avatar
    22 posts
    Member since:
    Aug 2012

    Posted 13 Oct 2012 Link to this post

    Hİ,

    I am using a custom connection for a special purpose and want to use MVVM. But I do not know how to create custom connection instance when using MVVM. Because it needs to be created and added to the diagram instance not the graphsource. Graphsource have AddLink method but it do not take RadDiagramConnection. Can you help me to find a way to use that Custom Connection class?
    Thank you,
    Sarper
  2. Answer
    Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 16 Oct 2012 Link to this post

    Hi Sarper,

     You should inherit the RadDiagram and override the GetConnectionContainerForItemOverride(object item) method. This method creates the actual visual connection (usually RadDiagramConnection) for every ILink object in your ViewModel, so if you override it and change the code to the following, it should work:

    protected overrideIConnection GetConnectionContainerForItemOverride(object item)
           {
               return new MyCustomConnection();
           }
    Let us know if this works for you.

    Regards,
    Miro Miroslavov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Sarper
    Sarper avatar
    22 posts
    Member since:
    Aug 2012

    Posted 16 Oct 2012 Link to this post

    Hi Miro Miroslavov, 

    I create custom diagram class and add that override method and.. It worked like a charm... I appreciated for your help really.
    I think that RadDiagram Framework is really good and flexible for all purposes. It has many features to customize and configure..
    Thank you.

    All the best,
    Sarper 
  5. Sammy
    Sammy avatar
    15 posts
    Member since:
    Aug 2008

    Posted 23 Jul 2014 Link to this post

    Hello,

    I have a further problem. If I drag a connection from a connector of a shape to a connector of another shape this override method also executed but the graphsource is not updated and the datacontext of the connection is not my custom modelview class. How can I make the diagram to update its graphsource with my custom modelview classes?

    Thanks,
  6. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 28 Jul 2014 Link to this post

    Hello,

    Could you please take a look at the attached project? It demonstrates how the RadDiagram should be used when you need to create derived connections and shapes in MVVM scenario. 

    Do not hesitate to ask if you need any further assistance.

    Regards,
    Pavel R. Pavlov
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready