Created
June 25, 2023 17:58
-
-
Save idiotandrobot/38ae2225f6ebc25676eb9e62aa82f38e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Application x:Class="WpfTrayIcon.App" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
ShutdownMode="OnExplicitShutdown" | |
> | |
<Application.Resources> | |
</Application.Resources> | |
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Configuration; | |
using System.Data; | |
using System.Windows; | |
using NotifyIcon = System.Windows.Forms.NotifyIcon; | |
namespace WpfTrayIcon | |
{ | |
public partial class App : Application | |
{ | |
public static NotifyIcon icon; | |
protected override void OnStartup(StartupEventArgs e) | |
{ | |
App.icon = new NotifyIcon(); | |
icon.Click += new EventHandler(icon_Click); | |
icon.Icon = new System.Drawing.Icon(typeof(App), "TrayIcon.ico"); | |
icon.Visible = true; | |
base.OnStartup(e); | |
} | |
private void icon_Click(Object sender, EventArgs e) | |
{ | |
MessageBox.Show("Thanks for clicking me"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment