Skip to content

Instantly share code, notes, and snippets.

@ridomin
Created February 5, 2018 05:29
Show Gist options
  • Select an option

  • Save ridomin/0f40c4f160a4f82b5b59d3589a632852 to your computer and use it in GitHub Desktop.

Select an option

Save ridomin/0f40c4f160a4f82b5b59d3589a632852 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Uwp.Notifications;
using Windows.UI.Notifications;
using Windows.Data.Xml.Dom;
namespace WpfAdoNetClient
{
public class Notifications
{
public static void Show()
{
ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
toastTextElements[0].AppendChild(toastXml.CreateTextNode("My notification from WPF"));
toastTextElements[1].AppendChild(toastXml.CreateTextNode(DateTime.Now.ToString()));
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment