Custom Connectors and MVVM

2 posts, 0 answers
  1. Sammy
    Sammy avatar
    15 posts
    Member since:
    Aug 2008

    Posted 15 Jul 2014 Link to this post

    Hi,

    I am using MVVM for RadDiagram control. I want to customize the connectors of the shapes, so that I can manage where the links are attached to. For shapes I use a ViewModel class which is derived from NodeViewModelBase and for links I use LinkViewModelBase<NodeViewModelBase>. How or on which layer should I manage the custom connectors? And how or where should I define them?

    Thanks in advance,

    Semih
  2. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 16 Jul 2014 Link to this post

    Hello Sammy,
    At the moment we don't support MVVM connectors out of the box (here's a feature request for this) but you could achieve something similar using an attached property:
    private static void OnConnectorsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var shape = d as RadDiagramShape;
        var connectors = e.NewValue as IEnumerable<ConnectorProxy>;
        if (shape != null && connectors != null)
        {
            shape.UseDefaultConnectors = false;
            foreach (var item in connectors)
            {
                shape.Connectors.Add(new RadDiagramConnector() { Name = item.Name, Offset = item.Position });
            }
        }
    }
    I've attached a sample project demonstrating this so could you please examine it and if you have more questions feel free to ask.

    Regards,
    Zarko
    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top