如何在 WPF 中不隐藏通知栏显示当前 window

How to display current window to notification bar NOT HIDE in WPF

我已经创建了一个 WPF 应用程序。它有一个 window 并且隐藏在关闭按钮上。但我想在通知栏中显示它。当用户点击它时,应该显示 windows。

这是我的代码:

public MainWindow()
{
    InitializeComponent();
    System.Timers.Timer aTimer = new System.Timers.Timer();
    aTimer.Elapsed += new ElapsedEventHandler(Timer_Elapsed);
    aTimer.Interval = 3000;
    aTimer.Enabled = true;

}

private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
    lblProcess.Content = "Test Window"

}

// minimize to system tray when applicaiton is closed
protected override void OnClosing(CancelEventArgs e)
{
    // setting cancel to true will cancel the close request
    // so the application is not closed
    e.Cancel = true;

    this.Hide();
    //this.Show();

    base.OnClosing(e);
}

我已经读过这个:create-popup-toaster-notifications-in-windows-with-net

minimizing-application-to-system-tray-using-wpf-not-using-notifyicon

minimizing-closing-application-to-system-tray-using-wpf

但是没听懂我该怎么做?

感谢任何帮助!

我已使用此代码:

System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon();
ni.Icon = new System.Drawing.Icon("D:\images.ico");
ni.Visible = true;
ni.DoubleClick +=delegate(object sender, EventArgs args)
               {
                  this.Show();
                  this.WindowState = WindowState.Normal;
               };