gpt4 book ai didi

WPF native Windows 10 toast

转载 作者:行者123 更新时间:2023-12-04 02:01:44 28 4
gpt4 key购买 nike

使用 .NET WPF 和 Windows 10,有没有办法使用 c# 将本地 Toast 通知推送到操作中心?我只看到人们为此制作自定义对话框,但必须有一种方法可以通过 os.

最佳答案

您可以使用 NotifyIcon来自 System.Windows.Forms命名空间是这样的:

class Test 
{
private readonly NotifyIcon _notifyIcon;

public Test()
{
_notifyIcon = new NotifyIcon();
// Extracts your app's icon and uses it as notify icon
_notifyIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
// Hides the icon when the notification is closed
_notifyIcon.BalloonTipClosed += (s, e) => _notifyIcon.Visible = false;
}

public void ShowNotification()
{
_notifyIcon.Visible = true;
// Shows a notification with specified message and title
_notifyIcon.ShowBalloonTip(3000, "Title", "Message", ToolTipIcon.Info);
}

}

这应该从 .NET Framework 1.1 开始工作。引用 this MSDN page对于 ShowBalloonTip 的参数.

正如我发现的, ShowBalloonTip 的第一个参数(在我的示例中,这将是 3000 毫秒)被慷慨地忽略。评论表示赞赏;)

关于WPF native Windows 10 toast ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35441202/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com