8
我想在用户最小化或关闭表单时在系统托盘中添加应用程序。我为Minimize案做了这件事。任何人都可以告诉我,当我关闭表单时,如何保持我的应用程序运行并将其添加到系统托盘中?使用WPF最小化/关闭应用程序到系统托盘
public MainWindow()
{
InitializeComponent();
System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon();
ni.Icon = new System.Drawing.Icon(Helper.GetImagePath("appIcon.ico"));
ni.Visible = true;
ni.DoubleClick +=
delegate(object sender, EventArgs args)
{
this.Show();
this.WindowState = System.Windows.WindowState.Normal;
};
SetTheme();
}
protected override void OnStateChanged(EventArgs e)
{
if (WindowState == System.Windows.WindowState.Minimized)
this.Hide();
base.OnStateChanged(e);
}
我建议您:https://visualstudiogallery.msdn.microsoft.com/aacbc77c-4ef6-456f-80b7-1f157c2909f7/ – Xaruth 2014-12-03 11:08:50