### Basic System Tray Setup in MainWindow Source: https://github.com/mehdimyadi/systemtraywinui3/blob/master/README.md Initialize the SystemTrayManager in your MainWindow to enable basic system tray features like tooltips and minimize-to-tray behavior. ```csharp public sealed partial class MainWindow : Window { private SystemTrayManager? systemTrayManager; private WindowHelper windowHelper; public MainWindow() { this.InitializeComponent(); // Initialize window helper windowHelper = new WindowHelper(this); // Initialize system tray manager systemTrayManager = new SystemTrayManager(windowHelper) { IconToolTip = "My WinUI 3 App", MinimizeToTray = true, CloseButtonMinimizesToTray = true }; // Set up settings action systemTrayManager.OpenSettingsAction = () => { // Navigate to your settings page MyFrame.Navigate(typeof(SettingsPage), systemTrayManager); }; } } ``` -------------------------------- ### SystemTrayManager Methods Source: https://github.com/mehdimyadi/systemtraywinui3/blob/master/README.md Methods to control the main window visibility and refresh the context menu. ```APIDOC ## SystemTrayManager Methods ### Description Methods to control the main window visibility and refresh the context menu. ### Methods | Method | Description | |----------------------------|----------------------------------------------| | `ToggleWindowVisibility()` | Show/hide the main window | | `RefreshContextMenu()` | Update context menu with current settings | ``` -------------------------------- ### Setting Custom System Tray Icons Source: https://github.com/mehdimyadi/systemtraywinui3/blob/master/README.md Configure the system tray icon using either a local .ico file or an icon from a system DLL. ```csharp // From .ico file SystemTrayIcon.Icon = new IcoIcon("Assets/CustomIcon.ico"); // From system DLL (like shell32.dll) SystemTrayIcon.Icon = new LibIcon("shell32.dll", 130); ``` -------------------------------- ### SystemTrayManager Properties Source: https://github.com/mehdimyadi/systemtraywinui3/blob/master/README.md Properties to configure the system tray icon's behavior and appearance. ```APIDOC ## SystemTrayManager Properties ### Description Properties to configure the system tray icon's behavior and appearance. ### Properties | Property | Type | Description | |----------------------------|--------|---------------------------------------------| | `IsIconVisible` | bool | Gets or sets tray icon visibility | | `LanguageCode` | string | Sets context menu language (e.g., "en", "fa", "ar") | | `IconToolTip` | string | Sets the tooltip text for the tray icon | | `MinimizeToTray` | bool | Enable/disable minimize to tray behavior | | `CloseButtonMinimizesToTray` | bool | Change close button behavior | ``` -------------------------------- ### Customize System Tray Context Menu Items Source: https://github.com/mehdimyadi/systemtraywinui3/blob/master/README.md Override the BuildMenuItems method to define custom context menu items. This includes custom actions, separators, and localized menu text. ```csharp private void BuildMenuItems() { var texts = MenuTranslations.TryGetValue(languageCode, out string[]? value) ? value : MenuTranslations["default"]; menuItems = [ new SystemTrayContextMenuWindow.Item("Custom Item", new Command(CustomAction)), new SystemTrayContextMenuWindow.Item("--", null), // Separator new SystemTrayContextMenuWindow.Item(texts[0], new Command(OpenSettings)), new SystemTrayContextMenuWindow.Item("--", null), new SystemTrayContextMenuWindow.Item(texts[1], new Command(() => Application.Current.Exit())) ]; } private void CustomAction() { // Your custom action here } ``` -------------------------------- ### SystemTrayManager Events Source: https://github.com/mehdimyadi/systemtraywinui3/blob/master/README.md Events that are fired when the tray icon is interacted with. ```APIDOC ## SystemTrayManager Events ### Description Events that are fired when the tray icon is interacted with. ### Events - LeftClick: Fired when tray icon is left-clicked - RightClick: Fired when tray icon is right-clicked ``` -------------------------------- ### Settings Page UI for System Tray Options Source: https://github.com/mehdimyadi/systemtraywinui3/blob/master/README.md Integrate UI elements in your settings page to control system tray icon visibility, minimize behavior, close button behavior, and language. ```xaml English فارسی العربية ``` -------------------------------- ### Dispose System Tray Manager on Application Exit Source: https://github.com/mehdimyadi/systemtraywinui3/blob/master/README.md Always dispose of SystemTrayManager and WindowHelper when your application exits to release resources. This is typically done in the OnClosed event handler. ```csharp protected override void OnClosed(EventArgs e) { systemTrayManager?.Dispose(); windowHelper?.Dispose(); base.OnClosed(e); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.