我创建了一个 WPF 应用程序。它有一个窗口,它隐藏在关闭按钮上。但我想在通知栏中显示它。当用户点击它时,应该显示窗口。
这是我的代码:
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
并最小化应用程序到系统托盘使用 wpf-not-using-notifyicon
但没有得到你我怎么能这样做?
任何帮助表示赞赏!