Context menu on Connection

5 posts, 0 answers
  1. donovan
    donovan avatar
    13 posts
    Member since:
    Oct 2011

    Posted 16 Jul 2014 Link to this post

    I can't figure out how to attach a RadContextMenu to a RadDiagramConnection.  Any help would be great.

    Thanks,
    Donovan
  2. Sammy
    Sammy avatar
    15 posts
    Member since:
    Aug 2008

    Posted 17 Jul 2014 in reply to donovan Link to this post

    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
  3. donovan
    donovan avatar
    13 posts
    Member since:
    Oct 2011

    Posted 17 Jul 2014 in reply to Sammy Link to this post

    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
  4. Sammy
    Sammy avatar
    15 posts
    Member since:
    Aug 2008

    Posted 17 Jul 2014 in reply to donovan Link to this post

    Hi Donovan,

    I think there is a mistake on the xaml, can you replace <ItemContainerTemplate> under <telerik:RadDiagramConnection.ContentTemplate> with <DataTemplate>.
  5. donovan
    donovan avatar
    13 posts
    Member since:
    Oct 2011

    Posted 17 Jul 2014 in reply to donovan Link to this post

    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>
Back to Top