Back to Devexpress

ToastNotificationsManager.UpdateToastContent Event

windowsforms-devexpress-dot-xtrabars-dot-toastnotifications-dot-toastnotificationsmanager-53b27983.md

latest6.1 KB
Original Source

ToastNotificationsManager.UpdateToastContent Event

Allows you to customize a notification’s content (visuals, actions, audio, etc.) according to the Toast Content Schema.

Namespace : DevExpress.XtraBars.ToastNotifications

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Behavior")]
public event EventHandler<UpdateToastContentEventArgs> UpdateToastContent
vb
<DXCategory("Behavior")>
Public Event UpdateToastContent As EventHandler(Of UpdateToastContentEventArgs)

Event Data

The UpdateToastContent event's data class is DevExpress.XtraBars.ToastNotifications.UpdateToastContentEventArgs.

Remarks

Handle the UpdateToastContent event to customize a notification’s content. To specify the content markup in code, use facilities provided in the System.XML namespace. To learn more about the content schema, see Toast Content Schema.

The code below adds an adaptive group with two subgroups. Each subgroup contains two text blocks, arranged vertically.

csharp
using System.Xml;

 public Form1() {
     InitializeComponent();
     //...
     toastNotificationsManager1.UpdateToastContent += ToastNotificationsManager1_UpdateToastContent;    
 }

 private void ToastNotificationsManager1_UpdateToastContent(object sender, DevExpress.XtraBars.ToastNotifications.UpdateToastContentEventArgs e) {
     XmlDocument content = e.ToastContent;
     XmlNode bindingNode = content.GetElementsByTagName("binding").FirstOrDefault();
     XmlElement group = content.CreateElement("group");
     bindingNode.AppendChild(group);

     //Create the first subgroup and add it to the root group.
     XmlElement subGroup = content.CreateElement("subgroup");
     group.AppendChild(subGroup);

     //Create the subgroup's first caption ("subgroup1").
     XmlElement text = content.CreateElement("text");
     subGroup.AppendChild(text);
     text.SetAttribute("hint-style", "base");
     text.InnerText = "subgroup1";

     //Create the subgroup's second caption ("captionSubtle").
     text = content.CreateElement("text");
     subGroup.AppendChild(text);
     text.SetAttribute("hint-style", "captionSubtle");
     text.InnerText = "captionSubtle";

     //Create the second subgroup and add it to the root group.
     subGroup = content.CreateElement("subgroup");
     group.AppendChild(subGroup);

     //Create the subgroup's first caption ("subgroup2").
     text = content.CreateElement("text");
     subGroup.AppendChild(text);
     text.SetAttribute("hint-style", "captionSubtle");
     text.SetAttribute("hint-align", "right");
     text.InnerText = "subgroup2";

     //Create the subgroup's second caption ("captionSubtle").
     text = content.CreateElement("text");
     subGroup.AppendChild(text);
     text.SetAttribute("hint-style", "captionSubtle");
     text.SetAttribute("hint-align", "right");
     text.InnerText = "captionSubtle";

     //Save the toast markup as an XML file for debugging purposes
     content.Save(@"D:\Toast.xml");
 }
vb
Imports System.Xml

 Public Sub New()
     InitializeComponent()
     '...
     AddHandler toastNotificationsManager1.UpdateToastContent, AddressOf ToastNotificationsManager1_UpdateToastContent
 End Sub

 Private Sub ToastNotificationsManager1_UpdateToastContent(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ToastNotifications.UpdateToastContentEventArgs)
     Dim content As XmlDocument = e.ToastContent
     Dim bindingNode As XmlNode = content.GetElementsByTagName("binding").FirstOrDefault()
     Dim group As XmlElement = content.CreateElement("group")
     bindingNode.AppendChild(group)

     'Create the first subgroup and add it to the rout group.
     Dim subGroup As XmlElement = content.CreateElement("subgroup")
     group.AppendChild(subGroup)

     'Create the subgroup's first caption ("subgroup1").
     Dim text As XmlElement = content.CreateElement("text")
     subGroup.AppendChild(text)
     text.SetAttribute("hint-style", "base")
     text.InnerText = "subgroup1"

     'Create the subgroup's second caption ("captionSubtle").
     text = content.CreateElement("text")
     subGroup.AppendChild(text)
     text.SetAttribute("hint-style", "captionSubtle")
     text.InnerText = "captionSubtle"

     'Create the second subgroup and add it to the root group.
     subGroup = content.CreateElement("subgroup")
     group.AppendChild(subGroup)

     'Create the subgroup's first caption ("subgroup2").
     text = content.CreateElement("text")
     subGroup.AppendChild(text)
     text.SetAttribute("hint-style", "captionSubtle")
     text.SetAttribute("hint-align", "right")
     text.InnerText = "subgroup2"

     'Create the subgroup's second caption ("captionSubtle").
     text = content.CreateElement("text")
     subGroup.AppendChild(text)
     text.SetAttribute("hint-style", "captionSubtle")
     text.SetAttribute("hint-align", "right")
     text.InnerText = "captionSubtle"

     'Save the toast markup as an XML file for debugging purposes
     content.Save("D:\Toast.xml")
 End Sub

See Also

ToastNotificationsManager Class

ToastNotificationsManager Members

DevExpress.XtraBars.ToastNotifications Namespace