Created
March 4, 2016 15:38
-
-
Save joemaidman/728783844d6fdc7d05ab to your computer and use it in GitHub Desktop.
Minimse c# window to systemtray
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
public partial class Window1 : System.Windows.Window | |
{ | |
public Window1() | |
{ | |
InitializeComponent(); | |
System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon(); | |
ni.Icon = new System.Drawing.Icon("Main.ico"); | |
ni.Visible = true; | |
ni.DoubleClick += | |
delegate(object sender, EventArgs args) | |
{ | |
this.Show(); | |
this.WindowState = WindowState.Normal; | |
}; | |
} | |
protected override void OnStateChanged(EventArgs e) | |
{ | |
if (WindowState == System.Windows.WindowState.Minimized) | |
this.Hide(); | |
base.OnStateChanged(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment