WPF native windows 10 toast

Using .NET WPF and Windows 10, is there a way to push local toast notification to the center of the action using C #? I only saw that people create special dialogs for this, but there must be a way to do this through os.

+6
source share
4 answers

You can use the NotifyIcon namespace from System.Windows.Forms as follows:

 class Test { private readonly NotifyIcon _notifyIcon; public Test() { _notifyIcon = new NotifyIcon(); // Extracts your app 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 with the .NET Framework 1.1. See this MSDN page for ShowBalloonTip options.

As I found out, the first parameter ShowBalloonTip (in my example, which will be 3000 milliseconds) is generously ignored. Comments are welcome;)

+2
source

UPDATE

It seems to work fine on Windows 10

https://msdn.microsoft.com/library/windows/apps/windows.ui.notifications.toastnotificationmanager.aspx

you will need to add these nugets

 Install-Package WindowsAPICodePack-Core Install-Package WindowsAPICodePack-Shell 
+2
source

I was able to access the working API for windows 8 and 10 by specifying

  • Windows.winmd: C: \ Program Files (x86) \ Windows \ 8.0 Kits \ Links \ CommonConfiguration \ Neutral

It provides Windows.UI.Notifications .

0
source

You can look at this post to create a COM server, which is necessary for notifications to be saved in AC using Win32 applications https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/10/16/quickstart-handling-toast -activations-from-win32-apps-in-windows-10 / .

A working sample can be found at https://github.com/WindowsNotifications/desktop-toasts

0
source

All Articles