{"id":18814374,"url":"https://github.com/nullsoftware/trayicon","last_synced_at":"2025-04-13T21:32:09.958Z","repository":{"id":144107598,"uuid":"412864622","full_name":"nullsoftware/TrayIcon","owner":"nullsoftware","description":"Tray Icon for WPF Application. Has wrapper for WPF ContexMenu.","archived":false,"fork":false,"pushed_at":"2024-03-13T10:08:20.000Z","size":189,"stargazers_count":16,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T13:57:04.989Z","etag":null,"topics":["balloon","notifier","notify","notify-icon","notifyicon","tray","tray-icon","tray-menu","trayicon","win32","wpf"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nullsoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-10-02T17:22:31.000Z","updated_at":"2025-04-09T10:19:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"f840f04f-f8b0-4abb-bb8b-89ee669b3ce1","html_url":"https://github.com/nullsoftware/TrayIcon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullsoftware%2FTrayIcon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullsoftware%2FTrayIcon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullsoftware%2FTrayIcon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullsoftware%2FTrayIcon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nullsoftware","download_url":"https://codeload.github.com/nullsoftware/TrayIcon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248786714,"owners_count":21161484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["balloon","notifier","notify","notify-icon","notifyicon","tray","tray-icon","tray-menu","trayicon","win32","wpf"],"created_at":"2024-11-07T23:40:35.410Z","updated_at":"2025-04-13T21:32:04.944Z","avatar_url":"https://github.com/nullsoftware.png","language":"C#","readme":"[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://stand-with-ukraine.pp.ua)\n\n[![](https://img.shields.io/nuget/vpre/TrayIcon)](https://www.nuget.org/packages/TrayIcon/)\n[![](https://img.shields.io/nuget/dt/TrayIcon)](https://www.nuget.org/packages/TrayIcon/)\n\n# Tray Icon\nLibrary that allows use Tray Icon in WPF Application. \nPorted from Windows Forms. Has wrapper for WPF ContexMenu (which converts it to Windows Forms ContextMenu). This is needed for good performance, and compatibility.\nThis library targets all MVVM requirements:\n- it has bindable properties\n- it has interface with notify methods\n\n## Getting started.\nUse one of the follwing methods to install and use this library:\n\n- **Package Manager:**\n\n    ```batch\n    PM\u003e Install-Package TrayIcon\n    ```\n\n- **.NET CLI:**\n\n    ```batch\n    \u003e dotnet add package TrayIcon\n    ```\n----\nFirst you need to include namespace to your code or markup.\n\nFor XAML it can look like:\n```XAML\n\u003cWindow xmlns:icon=\"https://github.com/nullsoftware/TrayIcon\" /\u003e\n```\n\nAnd for C#:\n```C#\nusing NullSoftware.ToolKit;\n```\n----\nThen you can place tray icon inside your window, or keep it in variable/property.  \n\nFor XAML:\n```XAML\n\u003cicon:TrayIconHandlers.TrayIcons\u003e\n    \u003cicon:TrayIcon Title=\"My Application\"\n                   IconSource=\"MainIcon.ico\"\n                   ClickCommand=\"{Binding ExampleCommand}\"\n                   NotificationServiceMemberPath=\"NotificationService\"/\u003e\n\u003c/icon:TrayIconHandlers.TrayIcons\u003e\n```\n\nFor C#:\n```C#\nTrayIcon myTrayIcon = new TrayIcon() \n{ \n    Title = \"My Application\",\n    IconSource = new BitmapImage(new Uri(\"pack://application:,,,/MainIcon.ico\")),\n    ClickCommand = new RelayCommand(ExampleAction)\n};\n```\n----\nTo show balloon you need to call `Notify` method:\n```C#\nINotificationService notifyService = myTrayIcon;\nnotifyService.Notify(\"Greetings\", \"Hello World!\", NotificationType.Information);\n```\n**Note:** `INotificationService` can be obtained from XAML by using `NotificationServiceMemberPath`.\nIt injects `INotificationService` to specified DataContext property.\n\n### Backward compatibility\nTo support latest .NET versions was added `ContextMenuVariation` property to `TrayIcon`.\\\nIt allows to switch beetwen `System.Windows.Forms.ContextMenu` or `System.Windows.Forms.ContextMenuStrip`.\\\n**Warning:** .NET Core 3.1 and later versions don't support `System.Windows.Forms.ContextMenu`.\nSee more at the [documentation page](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.contextmenu). \n\n## Full Example\n```XAML\n\u003cWindow x:Class=\"TrayIcon.Example.MainWindow\"\n        xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n        xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n        xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n        xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n        xmlns:local=\"clr-namespace:TrayIcon.Example\"\n        xmlns:vm=\"clr-namespace:TrayIcon.Example.ViewModels\"\n        xmlns:icon=\"https://github.com/nullsoftware/TrayIcon\"\n        mc:Ignorable=\"d\"\n        Title=\"MainWindow\" \n        Height=\"450\" Width=\"800\"\n        Icon=\"MainIcon.ico\"\u003e\n    \u003cWindow.DataContext\u003e\n        \u003cvm:MainViewModel/\u003e\n    \u003c/Window.DataContext\u003e\n\n    \u003c!--Here you can place your icons--\u003e\n    \u003cicon:TrayIconHandlers.TrayIcons\u003e\n        \u003cicon:TrayIcon Title=\"My Application\"\n                       IconSource=\"MainIcon.ico\"\n                       DoubleClickCommand=\"{Binding MinimazeCommand}\"\n                       NotificationServiceMemberPath=\"NotificationService\"\u003e\n            \u003cicon:TrayIcon.ContextMenu\u003e\n                \u003c!--This context menu will be converted to System.Windows.Forms.ContextMenu--\u003e\n                \u003cContextMenu\u003e\n                    \u003cMenuItem Header=\"Notify\" Command=\"{Binding SayHelloCommand}\" icon:TrayIcon.IsDefault=\"True\"/\u003e\n                    \u003cSeparator/\u003e\n                    \u003cMenuItem Header=\"_Silent Mode\" IsCheckable=\"True\" IsChecked=\"{Binding IsSilentModeEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}\"/\u003e\n                    \u003cSeparator/\u003e\n                    \u003cMenuItem Header=\"E_xit\" Command=\"{Binding CloseCommand}\"/\u003e\n                \u003c/ContextMenu\u003e\n            \u003c/icon:TrayIcon.ContextMenu\u003e\n        \u003c/icon:TrayIcon\u003e\n    \u003c/icon:TrayIconHandlers.TrayIcons\u003e\n\n    \u003cGrid\u003e\n        \u003cStackPanel VerticalAlignment=\"Top\"\n                    HorizontalAlignment=\"Left\"\n                    Margin=\"10, 20\"\n                    Orientation=\"Horizontal\"\u003e\n            \u003cCheckBox VerticalAlignment=\"Center\"\n                      IsChecked=\"{Binding IsSilentModeEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}\"\n                      Content=\"Silent Mode\"/\u003e\n            \u003cButton Margin=\"20, 0, 0, 0\"\n                    Padding=\"10, 3\"\n                    MinWidth=\"86\"\n                    Command=\"{Binding SayHelloCommand}\"\n                    Content=\"Notify\"/\u003e\n        \u003c/StackPanel\u003e\n    \u003c/Grid\u003e\n\u003c/Window\u003e\n```\nViewModel:\n```C#\nusing System;\nusing System.Windows.Input;\nusing NullSoftware.ToolKit;\nusing PropertyChanged;\n\npublic class MainViewModel : ObservableObject\n{\n    public bool IsSilentModeEnabled { get; set; }\n\n    [DoNotNotify]\n    public ICommand MinimazeCommand { get; }\n\n    [DoNotNotify]\n    public ICommand SayHelloCommand { get; }\n\n    [DoNotNotify]\n    public ICommand CloseCommand { get; }\n    \n    [DoNotNotify]\n    private INotificationService NotificationService { get; set; }\n\n    public MainViewModel()\n    {\n        MinimazeCommand = new RelayCommand(() =\u003e App.Current.MainWindow.WindowState = System.Windows.WindowState.Minimized);\n        SayHelloCommand = new RelayCommand(() =\u003e NotificationService.Notify(\"Greetings\", \"Hello World!\"));\n        CloseCommand = new RelayCommand(App.Current.MainWindow.Close);\n    }\n}\n```\n**Note:** in ViewModel was used [PropertyChanged.Fody](https://github.com/Fody/PropertyChanged) plugin, to simplify usage of `INotifyPropertyChanged`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullsoftware%2Ftrayicon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnullsoftware%2Ftrayicon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullsoftware%2Ftrayicon/lists"}