我想使用 WPF 将应用程序最小化到系统托盘。“NotifyIcon”是实现此结果的唯一方法吗?如果是,在 WPF 中使用“NotifyIcon”需要哪个命名空间?
如果可能使用“NotifyIcon”,请提供一些提示,我如何在我的主窗口中使用它?
我的主要窗口是,
public partial class MonthView : MetroWindow
{
public DateTime SelectedDate { get; set; }
public MonthView()
{
InitializeComponent();
calMain.DisplayDate = DateTime.Today;
Globals._globalController = new AppController();
Globals._globalController.appTaskManager.setupLocal();
Globals._globalController.setMonthViewWindow(this);
}
public void calItemSelectedDate(object sender, SelectionChangedEventArgs e)
{
DateTime d;
if (sender is DateTime)
{
d = (DateTime)sender;
}
else
{
DateTime.TryParse(sender.ToString(), out d);
}
SelectedDate = d;
ShowActivity(d);
}
public void ShowActivity(DateTime date)
{
DayView Activity = new DayView(date);
Activity.Show();
this.Hide();
}
private void SetButton_Click(object sender, RoutedEventArgs e)
{
SettingsView set = new SettingsView();
set.Show();
this.Hide();
}
}