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

Adding Custom Connectors in XAML style

6 Answers 185 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
AshR
Top achievements
Rank 1
AshR asked on 24 Feb 2015, 01:02 PM
In the documentation all custom connectors are added in code behind http://docs.telerik.com/devtools/wpf/controls/raddiagram/features/custom-connectors.html

I have also seen custom connectors added to individual raddiagramshape in xaml as :-

<telerik:RadDiagramShape Content="2"
                         Position="300 100"
                         UseDefaultConnectors="False">
    <telerik:RadDiagramShape.Connectors>
        <telerik:RadDiagramConnector Name="TopLeft"
                                     Offset="1 0.33" />      
    </telerik:RadDiagramShape.Connectors>
</telerik:RadDiagramShape>

However I use MVVM model and a shape style selector and do not have direct access. I cannot set 'Connectors' in a style using 'Settter Property=' because the connectors collection only has a get accessor. 

Is there a way to add custom connectors to a raddiagramshape in the XAML style?


telerik:RadDiagramShape Content="2"
                         Position="300 100"
                         UseDefaultConnectors="False">
    <telerik:RadDiagramShape.Connectors>
        <telerik:RadDiagramConnector Name="Left"
                                     Tag="Connector 1"
                                     Offset="0 0.5" />
        <telerik:RadDiagramConnector Name="Top"
                                     Tag="Connector 2"
                                     Offset="0.5 0" />
        <telerik:RadDiagramConnector Name="Right"
                                     Tag="Connector 3"
                                     Offset="1 0.5" />
        <telerik:RadDiagramConnector Name="Bottom"
                                     Tag="Connector 4"
                                     Offset="0.5 1" />
        <telerik:RadDiagramConnector Name="Auto"
                                     Tag="Connector 5"
                                     Offset="0.5 0.5" />
    </telerik:RadDiagramShape.Connectors>
</telerik:RadDiagramShape>
<telerik:RadDiagramShape Content="2"
                         Position="300 100"
                         UseDefaultConnectors="False">
    <telerik:RadDiagramShape.Connectors>
        <telerik:RadDiagramConnector Name="Left"
                                     Tag="Connector 1"
                                     Offset="0 0.5" />
        <telerik:RadDiagramConnector Name="Top"
                                     Tag="Connector 2"
                                     Offset="0.5 0" />
        <telerik:RadDiagramConnector Name="Right"
                                     Tag="Connector 3"
                                     Offset="1 0.5" />
        <telerik:RadDiagramConnector Name="Bottom"
                                     Tag="Connector 4"
                                     Offset="0.5 1" />
        <telerik:RadDiagramConnector Name="Auto"
                                     Tag="Connector 5"
                                     Offset="0.5 0.5" />
    </telerik:RadDiagramShape.Connectors>
</telerik:RadDiagramShape>
<telerik:RadDiagramShape Content="2"
                         Position="300 100"
                         UseDefaultConnectors="False">
    <telerik:RadDiagramShape.Connectors>
        <telerik:RadDiagramConnector Name="Left"
                                     Tag="Connector 1"
                                     Offset="0 0.5" />
        <telerik:RadDiagramConnector Name="Top"
                                     Tag="Connector 2"
                                     Offset="0.5 0" />
        <telerik:RadDiagramConnector Name="Right"
                                     Tag="Connector 3"
                                     Offset="1 0.5" />
        <telerik:RadDiagramConnector Name="Bottom"
                                     Tag="Connector 4"
                                     Offset="0.5 1" />
        <telerik:RadDiagramConnector Name="Auto"
                                     Tag="Connector 5"
                                     Offset="0.5 0.5" />
    </telerik:RadDiagramShape.Connectors>
</telerik:RadDiagramShape>

6 Answers, 1 is accepted

Sort by
0
Kiril Vandov
Telerik team
answered on 25 Feb 2015, 12:41 PM
Hello Ashley Rolleston,

In order to add your own connectors using MVVM you will need to create an Attached property to the RadDiagramShape and bind its Value to a collection from your ViewModel. In the attached property you have direct access to the shape and its Connectors collection and you could add the new connections to the collection. Also you could choose to either ignore or use the default five connectors using the UseDefaultConnectors property of the shape.

I have attached a sample project for your convenience demonstrating the approach. Please let us know if you need further assistance.

Regards,
Kiril Vandov
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.

 
0
AshR
Top achievements
Rank 1
answered on 26 Feb 2015, 08:54 AM
Thanks for the reply Kiril,

I can't see the attached sample project you mentioned?
0
Pavel R. Pavlov
Telerik team
answered on 26 Feb 2015, 09:39 AM
Hello Ashley,

It seems that something went wrong with the file upload. I have re-uploaded the solution and you should see it now.

Regards,
Pavel R. Pavlov
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.

 
0
AshR
Top achievements
Rank 1
answered on 27 Feb 2015, 03:02 PM
Thank you for your assistance.
0
Jakub
Top achievements
Rank 1
answered on 26 Jun 2015, 05:41 AM

Hallo Pavel,

 

I'd like to ask you if there is some difference in this scenario if i would like to use it with RadDiagramContainerShape. I've tried in my project and also in your scenario and it does not work. Could you be so kind and give me some advices how to use custom connectors through attached property on your sample project? 

 

Thank you very much for your time
Greetings Jakub

0
Jakub
Top achievements
Rank 1
answered on 26 Jun 2015, 06:14 AM

Hi Pavel,

 

problem solved sorry for spam:)

 

Have a nice day.

Jakub

Tags
Diagram
Asked by
AshR
Top achievements
Rank 1
Answers by
Kiril Vandov
Telerik team
AshR
Top achievements
Rank 1
Pavel R. Pavlov
Telerik team
Jakub
Top achievements
Rank 1
Share this question
or