Minimize a WPF application to System Tray in C#

Roman Reiter 1 Reputation point


First of all, I want to create a WPF that can be minimized in the Windows taskbar (next to the clock).

Second, I want to change the WPF's Incon icon when the wpf is minimized.

Thirdly, when the WPF is minimized, it should display action messages (such as Outlook when you receive an email or display a message to the user when a connection is lost).

BW Roman

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,700 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Lex Li (Microsoft) 5,072 Reputation points Microsoft Employee

    The true difficulty was that WPF on .NET Framework never has a tray icon control. But if you use the WinForms tray icon control, you just need a few lines of code to implement the feature,

    You might use third party tray icon for WPF as well.

    1 person found this answer helpful.

  2. Rod At Work 866 Reputation points

    If you want it in the system tray I think what you'll have to do is make it a Windows service. I've only written 1 Windows Service and that was years ago, but I believe that's what you'll have to do.

    If I'm correct about writing a Windows service, then what I would suggest you do is create a new Visual Studio solution and add two projects to it. One would be a DLL which would run as a Windows service. The second project would be a WPF project that will be your UI the user interacts with. Then you'll have to use some messaging system to communicate between the two.

    For the action messages that would mimic what Outlook does, I've used some WPF toast messages to accomplish that. If you Bing/Google "WPF toast popup" you'll get lots of results.

    I hope this helps.

    0 comments No comments