Hi,
To have only one menu item of a drop down menu checked, you can subscribe to the
MouseDown event of the menu items collection and uncheck all but the clicked menu item in the event handler.
Here's how to create a simple drop down menu:
NMenuDropDown menu = new NMenuDropDown("Menu");
menu.Items.Add(new NCheckableMenuItem("Item 1"));
menu.Items.Add(new NCheckableMenuItem("Item 2"));
menu.Items.Add(new NCheckableMenuItem("Item 3"));
menu.Items.Add(new NCheckableMenuItem("Item 4"));
menu.Items.MouseDown += OnMenuItemsMouseDown;
Here's how to uncheck all but the clicked menu item in the event handler:
private void OnMenuItemsMouseDown(NMouseButtonEventArgs arg)
{
// Get the menu items and the clicked menu item
NMenuItemCollection menuItems = (NMenuItemCollection)arg.CurrentTargetNode;
NCheckableMenuItem clickedMenuItem = arg.TargetNode is NCheckableMenuItem ?
(NCheckableMenuItem)arg.TargetNode :
arg.TargetNode.GetFirstAncestor<NCheckableMenuItem>();
// Uncheck all but the clicked menu item
for (int i = 0; i < menuItems.Count; i++)
{
NCheckableMenuItem currentItem = menuItems[i] as NCheckableMenuItem;
if (currentItem != clickedMenuItem)
{
currentItem.Checked = false;
}
}
}
Best Regards,
Nevron Support Team