Skip to content

Instantly share code, notes, and snippets.

@idiotandrobot
Created June 25, 2023 17:58
Show Gist options
  • Save idiotandrobot/38ae2225f6ebc25676eb9e62aa82f38e to your computer and use it in GitHub Desktop.
Save idiotandrobot/38ae2225f6ebc25676eb9e62aa82f38e to your computer and use it in GitHub Desktop.
<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>
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