Avalonia: Tray & Menu bar icon?

Created on 12 Jun 2019  路  21Comments  路  Source: AvaloniaUI/Avalonia

Hi,
Does Avalonia currently support System Tray Icon (Windows) and Menu Bar Icon (MacOS)? In order to minimize and hide the main app window, but still run in the background?

enhancement

Most helpful comment

Planned to be available this year.

All 21 comments

Currently blocked by https://github.com/AvaloniaUI/Avalonia/issues/898 https://github.com/AvaloniaUI/Avalonia/pull/2582
The same "menu export" infrastructure is needed for tray menus for OSX and Linux

is this still blocked ?

Planned to be available this year.

Is it possible to do this for OS X using MonoMac.Standard or will there be some conflict with Avalonia's codebase?

Using MonoMac for tray icons should work.

Any ETA or news about it? I was thinking about create an app that needs system tray support, actually I tried Xamarin.Forms and work well with it, but the poor support of multiple windows make me search other libs and check Avalonia, I just want a way to hook code into the NSAppDelegate and WPF Application in order to support NSStatusItem and NotifyIcon

Lack of System Tray support is indeed a problem - one of the basic Windows persistent application enhancements is not possible. Is there a way to add tray icon using native dll bindings which was already done anywhere else, so that it can be included with conditional compilation flags for Windows build?

Just for windows u can use this code:
https://github.com/MonkAlex/MangaReader/tree/master/MangaReader.Avalonia/Platform/Win
its copied from hardcodet.net, WPF removed
context menu not supported

Brillant, many thanks!

We were able to implement this on all 3 platforms (Win, Nix and OSX) but we had to use native bindings and dependencies....
The biggest issue is Linux which works as long as people use "the right" window manager and "the right" notification deamon... its a damn nightmare.
If anyone is interested here's an Implementation for Linux on Avalonia using Eto
https://github.com/sqrldev/SQRLDotNetClient/blob/master/SQRLDotNetClientUI/Platform/Linux/NotifyIcon.cs
One for OSX Using MonoMac
https://github.com/sqrldev/SQRLDotNetClient/blob/master/SQRLDotNetClientUI/Platform/OSX/NotifyIcon.cs

And Windows using Native windows Interop
https://github.com/sqrldev/SQRLDotNetClient/blob/master/SQRLDotNetClientUI/Platform/Win/NotifyIcon.cs

All using a common interface
https://github.com/sqrldev/SQRLDotNetClient/blob/925abc8200be52c5969632eac05368b5b94bb34e/SQRLDotNetClientUI/Models/INotifyIcon.cs

To call it from Avalonia
https://github.com/sqrldev/SQRLDotNetClient/blob/b2463a079559d7a56d73821697c412d2eb4f2b93/SQRLDotNetClientUI/App.xaml.cs#L87-L124

we could look at https://github.com/hardcodet/wpf-notifyicon for ideas on api design.

@josegomez Many thanks, this is working great.

NP @MikeAndrews90 glad it works for you, we've been using it for a while now works great, linux is still kinda ify depending on whether they are running GNOME or KDE, or Random other thing... but it mostly works.
That's always the issue with Linux there are 400 ways of doing the same thing and none of them are "standard"

@josegomez Thanks for providing this! I tested it just on Windows and it worked fine except the icon would pop back up in the system tray after quitting the program. I fixed this by manually calling NotifyIcon.Remove() on the Desktop_Exit event. I see there's a deconstructor that does the same thing but for whatever reason it's not firing.

I would totally use this but unfortunately it's GPL. Anyone know if the Avolonia team still working on their own solution?

GPL license? 馃 can I ask why that matters in your case just curious @seanocali

GPL license? 馃 can I ask why that matters in your case just curious @seanocali

Because any software I use it in would legally also have to be GPL.

@seanocali we are planning to support this, after 0.10 release

@danwalmsley I'm very excited for this feature! It's the only thing hindering me from porting my application to Avalonia.

@danwalmsley I'm very excited for this feature! It's the only thing hindering me from porting my application to Avalonia.

Same here. This is mandatory for me.

Its definately coming... if someone wants to make a PR it could come sooner... and there is nothing to stop users doing this today by calling the native apis themselves.

It shouldnt be a huge amount to work I dont think to add this.

Ok. Sorry, you guys are doing a splendid job ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grokys picture grokys  路  4Comments

kekekeks picture kekekeks  路  4Comments

Urgau picture Urgau  路  3Comments

Suriman picture Suriman  路  3Comments

JonathaN7Shepard picture JonathaN7Shepard  路  4Comments