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

Context menu on Connection

4 Answers 134 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
donovan
Top achievements
Rank 1
donovan asked on 17 Jul 2014, 01:26 AM
I can't figure out how to attach a RadContextMenu to a RadDiagramConnection.  Any help would be great.

Thanks,
Donovan

4 Answers, 1 is accepted

Sort by
0
Sammy
Top achievements
Rank 1
answered on 17 Jul 2014, 05:14 AM
Hi Donovan,

You should create a derived usercontrol class from RadDiagramConnection class. Then, on the xaml you can edit the ContentTemplate of your custom usercontrol.

Regards,
Semih
0
donovan
Top achievements
Rank 1
answered on 17 Jul 2014, 01:13 PM
Hi Semih,

Thanks for the idea. This is what I tried

​<telerik:RadDiagramConnection x:Class="Desktop.Shapes.Connection"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:desktop="clr-namespace:Desktop"
xmlns:viewModels="clr-namespace:Desktop.ViewModels"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<telerik:RadDiagramConnection.DataContext>
<viewModels:ConnectionViewModel/>
</telerik:RadDiagramConnection.DataContext>
<telerik:RadDiagramConnection.ContentTemplate>
<ItemContainerTemplate>
<Grid>
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu>
<telerik:RadMenuItem Command="desktop:Commands.PropertiesCommand" CommandParameter="{Binding}" />
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</Grid>
</ItemContainerTemplate>
</telerik:RadDiagramConnection.ContentTemplate>
</telerik:RadDiagramConnection>

But I still get the context menu of the RadDiagram and not the connection. I created my own RadDiagram derived class and I overrode GetConnectionContainerForItemOverride and  IsItemItsOwnConnectionContainerOverride to make sure my connection was used.

Can you see what I am doing wrong?

Thanks
Donovan
0
Sammy
Top achievements
Rank 1
answered on 17 Jul 2014, 01:17 PM
Hi Donovan,

I think there is a mistake on the xaml, can you replace <ItemContainerTemplate> under <telerik:RadDiagramConnection.ContentTemplate> with <DataTemplate>.
0
donovan
Top achievements
Rank 1
answered on 17 Jul 2014, 01:22 PM
I got it!

​<telerik:RadDiagramConnection x:Class="Desktop.Shapes.Connection"                              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:desktop="clr-namespace:Desktop"
xmlns:viewModels="clr-namespace:Desktop.ViewModels"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">

<telerik:RadDiagramConnection.DataContext>
<viewModels:ConnectionViewModel/>
</telerik:RadDiagramConnection.DataContext>
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu>
<telerik:RadMenuItem Command="desktop:Commands.PropertiesCommand" CommandParameter="{Binding}" />
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</telerik:RadDiagramConnection>
Tags
Diagram
Asked by
donovan
Top achievements
Rank 1
Answers by
Sammy
Top achievements
Rank 1
donovan
Top achievements
Rank 1
Share this question
or