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

custom connector shape

3 Answers 70 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
al
Top achievements
Rank 1
al asked on 17 Aug 2016, 02:06 PM

hi dear supporters,

I need to change the shape of connectors of a shape to a custom shape that is a jpg or other image formats.

how can I do that?

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 22 Aug 2016, 12:23 PM
Hi,

You can create a custom style with TargetType=":RadDiagramConnector" and set it to the ConnectorStyle property of the RadDiagramShape. Then you can override the default template of the connector by creating custom ControlTemplate and set it to the Template property of the RadDiagramConnector. Take a look at the following code.
<Window.Resources>
    <ControlTemplate x:Key="connectorTemplate" TargetType="telerik:RadDiagramConnector">
        <Image Source="/MyProject;component/Images/MyPictureName.jpg"  Stretch="UniformToFill"/>
    </ControlTemplate>
    <Style x:Name="customImageConnector" TargetType="telerik:RadDiagramConnector">
        <Setter Property="Template" Value="{StaticResource connectorTemplate}"/>
    </Style>
</Window.Resources>
<Grid>
    <telerik:RadDiagram>
        <telerik:RadDiagramShape x:Name="Shape1" Position="100,300" Content="Shape1" IsSelected="True" ConnectorStyle="{Binding customImageConnector}" />
    </telerik:RadDiagram>
</Grid>

Hope this information is useful.

Regards,
Dinko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
al
Top achievements
Rank 1
answered on 22 Aug 2016, 01:00 PM

hi and thank you.

i need to do all of it in the code behind not xaml and resources.

can you provide me a sample code for that?

Best regards,

0
al
Top achievements
Rank 1
answered on 22 Aug 2016, 02:00 PM

thank you Dinko. it worked.

i defined the rosourve in XAML (and changed the name to key in x:Name="customImageConnector") and then i get the resource by the below command:

Style s=FindResources("customImageConnector") as Style;

connector.Style=s;

thank you,

Tags
Diagram
Asked by
al
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
al
Top achievements
Rank 1
Share this question
or