Electron.Tray.OnClick don't work after calling Electron.Tray.Destroy() and then calling Electron.Tray.Show again #906

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

Originally created by @hswlab on GitHub (Aug 23, 2023).

Originally assigned to: @GregorBiswanger on GitHub.

🚨 The issue tracker is not for questions 🚨
Hi, I have a configuration in my app to enable or disable the tray icon.

When I'm enabling the Tray Icon for the first time with the code below, the on click works just fine.

string absolutePath = Path.Combine(webHostEnvironment.WebRootPath, "favicon.ico");
await Electron.Tray.Show(absolutePath, trayMenu);
Electron.Tray.OnClick += async (args, rectangle) => {Electron.WindowManager.BrowserWindows.First().Show();};

For hiding the Tray Icon I'm calling

Electron.Tray.Destroy();

But when I'm calling the first code to show the Tray Icon again, it just shows me the Icon, but the OnClick is not working. Am I doing something wrong, or is this a bug?

I'm using ElectronNET.API 23.6.1 and .NET6

Originally created by @hswlab on GitHub (Aug 23, 2023). Originally assigned to: @GregorBiswanger on GitHub. 🚨 The issue tracker is not for questions 🚨 Hi, I have a configuration in my app to enable or disable the tray icon. When I'm enabling the Tray Icon for the first time with the code below, the on click works just fine. ``` csharp string absolutePath = Path.Combine(webHostEnvironment.WebRootPath, "favicon.ico"); await Electron.Tray.Show(absolutePath, trayMenu); Electron.Tray.OnClick += async (args, rectangle) => {Electron.WindowManager.BrowserWindows.First().Show();}; ``` For hiding the Tray Icon I'm calling ``` csharp Electron.Tray.Destroy(); ``` But when I'm calling the first code to show the Tray Icon again, it just shows me the Icon, but the OnClick is not working. Am I doing something wrong, or is this a bug? I'm using ElectronNET.API 23.6.1 and .NET6
claunia added the question label 2026-01-29 16:51: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#906