使用.NET WPF和Windows 10,有没有办法使用c#将本地toast通知推送到操作中心?我只看到人们为此制作自定义对话框,但必须有一种方法可以通过 os.
您可以使用NotifyIcon
from 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 开始工作。参考这个 MSDN 页面 https://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon%28v=vs.110%29.aspx对于参数ShowBalloonTip
.
据我发现,第一个参数ShowBalloonTip
(在我的示例中为 3000 毫秒)被慷慨地忽略。感谢评论;)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)