[Solved] RadMenuItem hierarchy

1 Answer 11 Views
Menu
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Carl asked on 02 Apr 2026, 05:28 PM

I have a hierarchical menu of RadMenuItems

Item

   SubItem

       SubSubItem

If I select SubSubItem, is there any way via recursion I could iterate back up the tree to the top Item menu?

I saw a post from 2013 that suggested storing references to the preceding menu item in the Tag property but I'm wondering if there is a better way now to do this?

Thanks

Carl

 

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 03 Apr 2026, 10:50 AM

Hello, Carl,

I am not familiar with what your existing setup looks like, but you can walk up the hierarchy using the HierarchyParent property on each RadMenuItem. Here's a recursive approach:

private RadMenuItem GetRootMenuItem(RadMenuItem item)
{
    if (item.HierarchyParent is RadMenuItem parent)
    {
        return GetRootMenuItem(parent);
    }
    Console.WriteLine("Root Item is: " + item.Text);
    return item;
}

HierarchyParent returns the parent in the menu tree. When you reach the top-level RadMenuItem, its HierarchyParent will no longer be a RadMenuItem (it will be the RadMenu itself), so the loop stops and you have your root item. So, when you pass any sub-menu item to this method, it returns the root menu item.

I hope this solution helps. If you have any other questions, do not hesitate to ask.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Menu
Asked by
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or