Class TrayIcon
Represents an application icon displayed in the Windows system tray, providing functionality to show, update, and interact with a tray icon and its associated tooltip and events.
Implements
Inherited Members
Namespace: WinUIEx
Assembly: WinUIEx.dll
Syntax
public class TrayIcon : IDisposable
Remarks
The TrayIcon class enables applications to display an icon in the system tray (notification area), respond to user interactions such as clicks and double-clicks, and show contextual flyouts. It manages the icon's visibility, tooltip, and icon image, and provides events for common user actions.
note
Make sure you keep a reference to the TrayIcon as long as you are relying on it in the tray, or the Garbage Collector will collect it and remove it from the tray.
Constructors
Name | Description |
---|---|
TrayIcon(uint, IconId, string) | Initializes a new instance of the TrayIcon class with the specified icon and tooltip text. |
TrayIcon(uint, string, string) | Initializes a new instance of the TrayIcon class with the specified icon and tooltip text. |
Properties
Name | Description |
---|---|
IsVisible | Gets or sets a value indicating whether this instance is visible in the tray. |
Tooltip | Gets or sets the tooltip displayed when hovering on the callout. Maximum length: 128 characters |
TrayIconId | Gets the unique identifier for the tray icon. |
Methods
Name | Description |
---|---|
CloseFlyout() | Force-closes the flyout if it is visible. |
Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
Dispose(bool) | Disposes this instance and cleans up any resources |
~TrayIcon() | |
SetIcon(IconId) | Sets the icon displayed for the application's taskbar window. |
SetIcon(string) | Sets the icon displayed for the application's taskbar button. |
Events
Name | Description |
---|---|
ContextMenu | Occurs when the user right-clicks the tray icon or selects the context menu from the keyboard. |
LeftDoubleClick | Occurs when the user double-clicks the left mouse button on the tray icon. |
RightDoubleClick | Occurs when the user double-clicks the tray icon with the right mouse button. |
Selected | Occurs when the user clicks the left mouse button on the tray icon or selects it via the keyboard. |