需添加并引用 using System.Windows.Forms;
using System.Drawing;
using System.Windows;
using System.Windows.Forms;
namespace Sample3_托盘图标NotificationIcon
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
private NotifyIcon _notifyIcon;
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
// Configure and show a notification icon in the system tray
_notifyIcon = new NotifyIcon
{
BalloonTipText = @"Hello, NotifyIcon!",
Text = @"Hello, NotifyIcon!",
Icon = new Icon("NotifyIcon.ico"),
Visible = true
};
_notifyIcon.ShowBalloonTip(1000);
}
}
}