-
-
Save k94ll13nn3/f3dce111e525a02c2bc9 to your computer and use it in GitHub Desktop.
Basic c# console app for showing a toast notification.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Windows.Data.Xml.Dom; | |
using Windows.UI.Notifications; | |
namespace ToastDesktop | |
{ | |
internal class Program | |
{ | |
/// You have to add in the .csproj: | |
/// <TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion> | |
/// I always put it in the <PropertyGroup/> which contains the <TargetFrameworkVersion/>. | |
/// | |
/// References to add : | |
/// - Windows.UI | |
/// - Windows.Data | |
private static void Main(string[] args) | |
{ | |
string xml = $@" | |
<toast> | |
<visual> | |
<binding template='ToastGeneric'> | |
<text>Some title</text> | |
<text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</text> | |
</binding> | |
</visual> | |
</toast>"; | |
XmlDocument doc = new XmlDocument(); | |
doc.LoadXml(xml); | |
ToastNotification toast = new ToastNotification(doc); | |
toast.Tag = "tag"; | |
toast.Group = "group"; | |
ToastNotificationManager.CreateToastNotifier("ToastDesktop").Show(toast); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For this to work with Windows 10 you must add a reference to: C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\1.0.0.0\Windows.Foundation.UniversalApiContract.winmd