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

How can I close popup when click a middle level menu item?

4 Answers 121 Views
Menu
This is a migrated thread and some comments may be shown as answers.
He
Top achievements
Rank 1
He asked on 13 Jul 2011, 07:54 AM
Hi, I am using RadMenu to create a three layer menu.
It is something like :    -TopMenu
                                        -SecondLevel1  -ThirdLevel
                                        -SecondLevel2  

Now, If I click "ThirdLevel" or "SecondLevel2", the menu will be closed automatically. But If I click "SecondLevel1", nothing happens. I know it is the logic you made it. But I want to close the menu when clicking "SecondLevel1". If there any way to do it?

4 Answers, 1 is accepted

Sort by
0
Dani
Telerik team
answered on 13 Jul 2011, 10:12 AM
Hi He Ying,

The click on the submenu header is used for opening another submenu. When you set a delay for the opening of the popup , the click on the header will still open it immediately despite the delay setting. So you cannot use the click on the header for other implementation purposes like closing the menu.
 
If you intend to use the desired functionality for marking a user's choice like selection among a variety of options, you might want to consider using checkable menu items. The menu items will be checkable if you set IsCheckable="True".

I hope this helps.


Best wishes,
Dani
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
He
Top achievements
Rank 1
answered on 13 Jul 2011, 10:57 AM
Hi, Dani

Thanks for your reply. But I do need "SecondLeve1" works the same as "ThirdLevel" when clicking in the example. The checkable menu item cannot solve my problem. Is there any method that can be used to close the popup in code?

Best Regards
He Ying
0
Valeri Hristov
Telerik team
answered on 15 Jul 2011, 01:36 PM
Hello,

RadMenu actually has a property named NotifyOnHeaderClick that was created especially for scenarios like yours. You need to set it to true and the menu will automatically close when you click on items with children. In addition, the ItemClick event will be fired.

Regards,
Valeri Hristov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Dani
Telerik team
answered on 15 Jul 2011, 02:43 PM
Hi He Ying,

You can try the following approach:
private void RadMenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
         RadMenuItem item = e.OriginalSource as RadMenuItem;
         while (item.Parent != null)
         {
                  var parent = System.Windows.Controls.ItemsControl.ItemsControlFromItemContainer(item) as RadMenuItem;
                 if (parent != null)
                 {
                          item = parent;
                 }
                 else
                 {
                          break;
                 }
         }
  
         var menuItemAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as RadMenuItemAutomationPeer;
         menuItemAutomationPeer.Collapse();
}

I hope this helps.


Best wishes,
Dani
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Menu
Asked by
He
Top achievements
Rank 1
Answers by
Dani
Telerik team
He
Top achievements
Rank 1
Valeri Hristov
Telerik team
Share this question
or