The default behavior when you click on a RadMenuItem
that doesn't have children, is to close the opened menu(if the property StaysOpenOnClick
is not set to true). That's why when you click on an item without children it is closing all items.Your code is just not closing the menu, it's the default behavior that is doing it.
To close the items you can use the code below in your ItemClick event handler:
RadMenuItemAutomationPeer CloseME =
(currentItem.HasItems && currentItem.IsSubmenuOpen ==
//collapse the children
currentItem = currentItem.Parent
It is collapsing the children of the current clicked item, finding the parent of the clicked item, collapsing its children, etc. Note that you'll have to set NotifyOnHeaderClick
on the RadMenu
to True if you want the ItemClick event to be fired when you click on an item that has children. I'm sending you a simple project demonstrating the usage of the code.
Hopefully this helps.
the Telerik team