Reputation: 1
Iam trying to add a App Icon to my Electron.Net Application but the Icon isn't Displayed in the Taskbar / System Tray,
What i did:
in electron.manifest.json i have
"linux": {
"icon": "../../../wwwroot/build/icons/256x256.png",
"category": "Office"
},
in the Startup.cs
var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions{
Width = 1280,
Height = 756,
Fullscreenable= false,
HasShadow= true,
AutoHideMenuBar=true,
Maximizable= false,
Icon = "../../../wwwroot/build/icons/32x32.png"
});
First i checked if the filepath is right and yes its right, i tryed different folders, different filenames but nothing worked.
I hope you guys can help me.
Upvotes: 0
Views: 1785
Reputation: 11
To create a tray icon, add this code on your app startup (Startup.cs in your case, Program.cs for NET6) before app.Run();
:
var TrayMenu = new MenuItem[]
{
new MenuItem{
Label = "Show window",
Click = () => { Electron.WindowManager.BrowserWindows.First().Show(); }
},
new MenuItem{
Label = "Hide",
Click = () => { Electron.WindowManager.BrowserWindows.First().Hide(); }
},
new MenuItem{
Label = "Quit",
Click = () => { Electron.App.Exit(0); }
}
};
Electron.Tray.Show("/your/logo/here.png", TrayMenu);
And as to it not showing in taskbar you probably disabled it somewhere in your code, provide more info. Perhaps it has something to do with your disabled fullscreen/resize thing in Startup.cs?
Upvotes: 1