Suppose there is a program that does certain operations in the background, no matter what, for example, every 10 seconds it collects information on the CPU and RAM load. The program itself is desktop, it is launched by handles, it would be necessary to make it so that it starts up in the autorun.

The question is: how to teach her that when she collapses she hides in the tray, and, if necessary, overturns any messages. For example, as Kaspersky antivirus. Hanging in the tray, overturns notifications when you open it - appears in the taskbar

    1 answer 1

    I am using Hardcodet.NotifyIcon.Wpf

    In XAML, add the namespace: xmlns:tb="http://www.hardcodet.net/taskbar"

    In the window container, place:

     <tb:TaskbarIcon Visibility="Visible" ToolTipText="..." IconSource="..."/> 

    To minimize the window to the tray, subscribe to the StateChanged event:

     WindowState prevState; private void Window_StateChanged(object sender, EventArgs e) { if (WindowState == WindowState.Minimized) Hide(); else prevState = WindowState; } 

    To expand, for example, when you left-click on the tray icon:

     private void TaskbarIcon_TrayLeftMouseDown(object sender, RoutedEventArgs e) { Show(); WindowState = prevState; } 

    To display any messages, you can use, for example, Popup or ToolTip