Skip to main content

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.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DXCategory("Behavior")]
public event EventHandler<UpdateToastContentEventArgs> UpdateToastContent

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.

Toast Notifications - Custom Template

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");
 }
See Also