RadMenuItem inside RadMenuItem

4 posts, 1 answers
  1. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 15 Apr 2009 Link to this post


    I've inherited some code and I'm just confused enough to wonder about what I'm doing anymore...  I have a menu object which has a n-level tree of menu options that I'd like to bind as the datasource for my RadMenu.  I seem to have it working properly except for the fact that I have a RadMenuItem inside another RadMenuItem because I can't figure out how else to get the click event.  I'm not an expert withi this so your patience is appreciated.

    I have a HierarchicalDataTemplate as follows:


    rad:HierarchicalDataTemplate x:Key="MenuItemDT" ItemsSource="{Binding Items}" >



       <menu:RadMenuItem Click="ctxMnuItem_Click" Header="{Binding Caption}" Icon="{Binding ImagePath, Converter={StaticResource










    And my RadMenu is defined as follows:
    <menu:RadMenu x:Name="mnuCtx">
       <menu:RadMenuItem ItemTemplate="{StaticResource MenuItemDT}" ItemsSource="{Binding ContextMenu.Items}">






              <Path Stretch="Fill" Fill="Black" Height="4" Width="8" Data="F1 M 531.107,321.943L 541.537,321.943L 536.322,328.042L
              531.107,321.943 Z" >














    When I run my project, everything loads and runs fine except my RadMenuItems contain RadMenuItems.  I thought about putting a "HeaderedContentControl" into "MenuItemDT" but then I don't have a place to assign my click event...
  2. Answer
    Valeri Hristov
    Valeri Hristov avatar
    2252 posts

    Posted 15 Apr 2009 Link to this post

    Hi Rob,

    The following example demonstrates how to handle the RadMenuItem.Click event in one place:

    The example is not databound, but the code will be the same. Please, let us know if you need further assistance.

    All the best,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. tl
    tl avatar
    5 posts
    Member since:
    Nov 2008

    Posted 28 Sep 2010 Link to this post


    I have the same problem like the original poster with a menuitem in a menuitem...The answer here from Telerik did not really helped me.

    -I know how to make a flat contextmenu bound to a datasource.
    -I know how to make subcontextmenus with static menuitems.

    ->But I don´t know how to make a subcontextmenu with databound items.
    I bind a datasource on one item and I have an itemtemplate in the item for the submenuitems.
    What happens is, that the subcontextmenu with the items are generated,
    but I have a double focus rectangle, it seems that there is a menuitem in a menuitem (but not as a subcontextmenu)

    Here is the XAML:

          <telerikNavigation:RadContextMenu x:Name="gridContextMenu">
              <telerikNavigation:RadMenuItem Header="Element öffnen" BdlCommands:RadMenuItemClick.Command="{Binding Path=DataSource.ContactEntryActionCommand, Source={StaticResource DataContextProxy}}" BdlCommands:RadMenuItemClick.CommandParameter="OpenCurrentEntry"/>
              <telerikNavigation:RadMenuItem Header="Element löschen" BdlCommands:RadMenuItemClick.Command="{Binding Path=DataSource.ContactEntryActionCommand, Source={StaticResource DataContextProxy}}" BdlCommands:RadMenuItemClick.CommandParameter="DeleteCurrentEntry"/>
              <telerikNavigation:RadMenuItem IsSeparator="True"/>
              <telerikNavigation:RadMenuItem Header="Neue Aktion" BdlCommands:RadMenuItemClick.Command="{Binding Path=DataSource.CreateNeueAktionCommand, Source={StaticResource DataContextProxy}}" BdlCommands:RadMenuItemClick.CommandParameter="CreateNeueAktion"/>
              <telerikNavigation:RadMenuItem Header="Neue Reaktion" BdlCommands:RadMenuItemClick.Command="{Binding Path=DataSource.CreateNeueReaktionCommand, Source={StaticResource DataContextProxy}}" BdlCommands:RadMenuItemClick.CommandParameter="CreateNeueReaktion"/>
              <telerikNavigation:RadMenuItem Header="Neuer Kontakt" ItemsSource="{Binding KontaktArten}">
                          <telerikNavigation:RadMenuItem Header="{Binding Name}" BdlCommands:RadMenuItemClick.Command="{Binding Path=DataSource.CreateNeuesKontaktCommand, Source={StaticResource DataContextProxy}}" BdlCommands:RadMenuItemClick.CommandParameter="{Binding}"/>

    What comes out is:

    Element öffnen
    Element öffnen
    Neue Aktion
    Neue Reaktion
    Neuer Kontakt>> Neuer Report          <-This sub items have a double focus rectangle
                                Neues Telefonat
  4. Hristo
    Hristo avatar
    832 posts

    Posted 30 Sep 2010 Link to this post

    Hello tl,

    You can see how to data bind multi level menu items in this example:

    The important part is using HierarchicalDataTemplate class where you can specify the source for the subItems:

    <telerik:HierarchicalDataTemplate x:Key="MenuItemTemplate" ItemsSource="{Binding Items}" telerik:ContainerBinding.ContainerBindings="{StaticResource ContainerBindings}">
       <TextBlock Text="{Binding Text}" />

    This demo is for RadMenu but the same code will work for all HierarchicalItemsControls like RadContextMenu, RadTreeView, etc.

    Let us know if you need additional information.

    Best wishes,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top