Skip to content

TrayIcon class

An icon the application shows in the system’s notification area or status bar, with an optional menu.

Guide: C# Markup guide

public sealed class TrayIcon : MewObject, IDisposable
name description
TrayIcon() The default constructor.
Command { get; set; }
CommandData { get; set; }
Commands { get; } Gets the scope the icon’s command and its menu’s commands resolve in before Commands.
ContextMenu { get; set; }
Icon { get; set; }
IsMonochromeIcon { get; set; }
IsVisible { get; set; }
ToolTipText { get; set; }
event Click Occurs when the platform reports a primary activation of the icon apart from opening its menu.
event DoubleClick Occurs on a double click where the platform reports one; its clicks raise Click as well.
event MenuOpening Occurs just before the menu opens; a handler may replace or fill ContextMenu.
Dispose() Removes the icon and releases its resources; the icon cannot be shown again.
static IsSupported { get; } Gets whether the running application’s platform has somewhere to show tray icons now; false before a run.
static readonly CommandDataProperty The value passed to Command as its invocation argument.
static readonly CommandProperty The command the icon runs when activated.
static readonly ContextMenuProperty The menu the icon opens; null for an icon without a menu.
static readonly IconProperty The icon image; null shows the application’s own icon.
static readonly IsMonochromeIconProperty Whether the icon is a single-color glyph that the platform may tint to match its status bar.
static readonly IsVisibleProperty Whether the icon is shown; false by default.
static readonly ToolTipTextProperty The text shown when the pointer rests on the icon.

Nothing appears until IsVisible is true while the application runs. The icon is removed when IsVisible turns false, when it is disposed, and when the run ends, which also disposes it. Use it on the UI thread. How the menu is presented follows each platform’s convention.