-
Hi all! I have just started using Avalonia UI. My goal is to enable system tray icon of an application, depending on preferences read from config file on startup. Currently I've found an example that makes it always enabled. Could you provide a sample of code in C#, that creates TrayIcon? |
Beta Was this translation helpful? Give feedback.
Answered by
tobyfirth
Dec 13, 2024
Replies: 1 comment
-
You can do something like this. var icons = new TrayIcons
{
new TrayIcon
{
Icon = new WindowIcon(new Bitmap(AssetLoader.Open(new Uri("avares://SmartbinderUI/Assets/avalonia-logo.ico")))),
Menu = [
new NativeMenuItem("Settings")
{
Menu = new NativeMenu
{
new NativeMenuItem("Option 1"),
new NativeMenuItem("Option 2"),
new NativeMenuItemSeparator(),
new NativeMenuItem("Option 3")
}
}
]
}
};
TrayIcon.SetIcons(Application.Current, icons); And to remove it. TrayIcon.SetIcons(Application.Current, null); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wl2776
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do something like this.
And to remove it.