需添加并引用 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);
}
}
}
本文介绍了一个使用C#创建系统托盘图标NotificationIcon的示例程序。该程序通过按钮点击事件展示托盘图标,并显示气球提示框。示例代码展示了如何配置和显示托盘图标。
707

被折叠的 条评论
为什么被折叠?



