Search code examples
c#wpfsystem-tray

minimize app to system tray - no icon appears


i need to minimize app to system tray (see my icon there). But after starting the app, the icon dissapears from taskbar (that is fine) but i cannot see it in system tray (that is bad).

enter image description here

Where can be a mistake, please? PS: i am using WPF.

This is inner code of my event:

System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon();
            if (WindowState.Minimized == this.WindowState)
            {
                notifyIcon.Visible = true;
                notifyIcon.BalloonTipText = "Radek app";
                notifyIcon.BalloonTipTitle = "Welcome Message";
                notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;                
                notifyIcon.ShowBalloonTip(3000);                
                this.ShowInTaskbar = false;
            }

            else if (WindowState.Normal == this.WindowState)
            {
                this.WindowState = WindowState.Normal;
                this.ShowInTaskbar = true;
                notifyIcon.Visible = false;
            }

Solution

  • You need to set the Icon as shown below:

    notifyIcon.Icon = new System.Drawing.Icon(Path to your Icon);