Using .NET WPF and Windows 10, is there a way to push a local toast notification onto the action center using c#? I\'ve only seen people making custom dialogs for that but there
You can use a NotifyIcon
from System.Windows.Forms
namespace like this:
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);
}
}
This should work since .NET Framework 1.1. Refer to this MSDN page for parameters of ShowBalloonTip
.
As I found out, the first parameter of ShowBalloonTip
(in my example that would be 3000 milliseconds) is generously ignored. Comments are appreciated ;)