.net.net-coreelectron.net

Electron.NET: How to add menu?


For example: the default menu is File, Edit, View, Window, Help

I’d like to add my menu item + subitems File, Edit, View, Tools (Options, Customize), Window, Help

How to do it? When I do as in example:

var menu = new MenuItem[]
{
new MenuItem
{
Label = “Tools”,
Click = async () =>
{
await Electron.Dialog.ShowMessageBoxAsync(“Hello, Tools!”);
}
}
};
Electron.Menu.SetApplicationMenu(menu);

It replaces existing menu with my menu Tools, but I need to add it to the existing.


Solution

  • The native Electron has a default development menu. If you add your own menu, this will be used. You can not use the development menu and your own menu together..