Context menu item "Enabled" property does not work. #332

Open
opened 2026-01-29 16:36:44 +00:00 by claunia · 0 comments
Owner

Originally created by @Tum4ik on GitHub (May 30, 2019).

Originally assigned to: @GregorBiswanger on GitHub.

  • Version:
    ElectronNET.CLI Version: 5.22.12.0
    ElectronNET.API Version: 5.22.12
    .NET Core Version: 2.2.300
    Node.js Version: 8.11.3

  • Target:
    Windows

I've created some menu items and one of them should be disabled at startup.

var runServerMenuItem = new MenuItem
{
  Label = _localizer["Run Server"],
  Icon = trayMenuRunIcon
};
var stopServerMenuItem = new MenuItem
{
  Label = _localizer["Stop Server"],
  Icon = trayMenuStopIcon,
  Enabled = false
};

var menuItems = new[]
{
  runServerMenuItem,
  stopServerMenuItem,
  new MenuItem
  {
    Label = _localizer["Settings"],
    Icon = trayMenuSettingIcon,
    Click = async () =>
    {
      _settingsWindow = await Electron.WindowManager.CreateWindowAsync(settingsWindowOptions);
      _settingsWindow.Center();
    }
  },
  new MenuItem
  {
    Label = _localizer["About"],
    Icon = trayMenuAboutIcon
  },
  new MenuItem
  {
    Type = MenuType.separator
  },
  new MenuItem
  {
    Label = _localizer["Exit"],
    Icon = trayMenuExitIcon,
    Click = () => Electron.App.Quit()
  }
};

Electron.WindowManager.IsQuitOnWindowAllClosed = false;
Electron.Tray.Show(TrayStopIcon, menuItems);

But, unfortunately, no effect. The "Stop Server" item is still enabled.
image

Originally created by @Tum4ik on GitHub (May 30, 2019). Originally assigned to: @GregorBiswanger on GitHub. * **Version**: ElectronNET.CLI Version: 5.22.12.0 ElectronNET.API Version: 5.22.12 .NET Core Version: 2.2.300 Node.js Version: 8.11.3 * **Target**: Windows I've created some menu items and one of them should be disabled at startup. ```csharp var runServerMenuItem = new MenuItem { Label = _localizer["Run Server"], Icon = trayMenuRunIcon }; var stopServerMenuItem = new MenuItem { Label = _localizer["Stop Server"], Icon = trayMenuStopIcon, Enabled = false }; var menuItems = new[] { runServerMenuItem, stopServerMenuItem, new MenuItem { Label = _localizer["Settings"], Icon = trayMenuSettingIcon, Click = async () => { _settingsWindow = await Electron.WindowManager.CreateWindowAsync(settingsWindowOptions); _settingsWindow.Center(); } }, new MenuItem { Label = _localizer["About"], Icon = trayMenuAboutIcon }, new MenuItem { Type = MenuType.separator }, new MenuItem { Label = _localizer["Exit"], Icon = trayMenuExitIcon, Click = () => Electron.App.Quit() } }; Electron.WindowManager.IsQuitOnWindowAllClosed = false; Electron.Tray.Show(TrayStopIcon, menuItems); ``` But, unfortunately, no effect. The "Stop Server" item is still enabled. ![image](https://user-images.githubusercontent.com/21317790/58656956-e9bcbd80-8325-11e9-8df8-bf8876d103f1.png)
claunia added the bug label 2026-01-29 16:36:44 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#332