Minimizing Application to system tray using WPF ( Not using NotifyIcon )
If you'll reconsider your reluctance to using an external component, I recommend WPF NotifyIcon. I've used it. It's straightforward and works well.
It does not just rely on the corresponding WinForms component, but is a purely independent control which leverages several features of the WPF framework in order to display rich tooltips, popups, context menus, and balloon messages.
I just came across this post today.
For reference, I also solved this some time back. It works very well and the only time I have had a bit of an issue is occasionally on some multi-display set ups.
This was before GITs and NuGets were the in-thing, I will place it in a GIT repo if there is interest.
Here is a thread , which helped me a lot .
https://stackoverflow.com/a/12428063/10305444
public partial class Window : System.Windows.Window{public Window(){ 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 == WindowState.Minimized) this.Hide(); base.OnStateChanged(e);}}