This is a migrated thread and some comments may be shown as answers.

Custom Connectors and MVVM

1 Answer 121 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Sammy
Top achievements
Rank 1
Sammy asked on 15 Jul 2014, 06:30 AM
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

1 Answer, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 16 Jul 2014, 01:01 PM
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.
 
Tags
Diagram
Asked by
Sammy
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Share this question
or