Introduction
A toast notification is a message used to display the information fast and an app can construct and deliver to the user is not currently using the app. Windows 10 toast notification have new adaptive templates and interactive actions we can set our toast layout our self, so it is also called Adaptive Toast.
Create a new Windows 10 UWP app.
Go to the code-behind page and add the following namespace.
Let’s see the steps
- using Windows.UI.Notifications;
- using NotificationsExtensions.Toasts;
- public static Windows.Data.Xml.Dom.XmlDocument CreateToast()
- {
- var xDoc = new XDocument(
- new XElement("toast",
- new XElement("visual",
- new XElement("binding", new XAttribute("template", "ToastGeneric"),
- new XElement("text", "C# Corner"),
- new XElement("text", "Do you got MVP award?")
- )
- ),// actions
- new XElement("actions",
- new XElement("action", new XAttribute("activationType", "background"),
- new XAttribute("content", "Yes"), new XAttribute("arguments", "yes")),
- new XElement("action", new XAttribute("activationType", "background"),
- new XAttribute("content", "No"), new XAttribute("arguments", "no"))
- )
- )
- );
- var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
- xmlDoc.LoadXml(xDoc.ToString());
- return xmlDoc;
- }
- var xmdock = CreateToast();
- var toast = new ToastNotification(xmdock);
- Next show the toast using ToastNotificationManager class.
- var notifi = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();
- notifi.Show(toast);
- private void showToastBtn_Click(object sender, RoutedEventArgs e)
- {
- var xmdock = CreateToast();
- var toast = new ToastNotification(xmdock);
- var notifi = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();
- notifi.Show(toast);
- }

Summary
In this article, we learned about Toast Notification In Windows 10 UWP.

Ahmad MustafaPosted Apr 15, 2020, 8:53 AM
Any idea how to change background color ?
sheeraz razaPosted Jul 2, 2019, 6:51 AM
Can we replace image with User Name initials like we see in Microsoft teams and outlook? Appreciate your help thanks.
Amit Kumar SinghPosted Feb 12, 2016, 4:04 AM
Good one
Joe WilsonPosted Jan 6, 2016, 5:01 AM
Thank you for sharing.
Santhakumar MunuswamyPosted Jan 5, 2016, 11:25 PM
Thanks for nice share
Kumaresh RajalingamPosted Jan 4, 2016, 9:11 PM
Nice one
Karthikeyan KPosted Jan 4, 2016, 7:33 AM
Good one
Sabyasachi MishraPosted Jan 4, 2016, 7:25 AM
Nice share