MSDN 有关 toast 文档:
http://msdn.microsoft.com/zh-cn/library/windows/apps/hh779727.aspx
模版 : http://msdn.microsoft.com/zh-cn/library/windows/apps/hh761494.aspx
win8 的 toast 通知和 wp 的类似。win 8 的 toast 是显示在屏幕右上角,可以有文字,也可以加上图片。系统的通知同时做多显示三个,
如果多余三个,就会把多余的通知放到系统队列中,然后各个 Toast 通知依次显示固定时间。
在 Windows.UI.Notifications 命名空间下的枚举:
// 摘要: // 指定要在消息通知中使用的模版。 public enum ToastTemplateType { // 摘要: // 在三行文本中被包装的大型图像和单个字符串。 ToastImageAndText01 = 0, // // 摘要: // 大图像、加粗文本的一个字符串在第一行、常规文本的一个字符串包装在第二、三行中。 ToastImageAndText02 = 1, // // 摘要: // 大图像、加粗文本的一个字符串被包装在开头两行中、常规文本的一个字符串包装在第三行中。 ToastImageAndText03 = 2, // // 摘要: // 大图像、加粗文本的一个字符串在第一行、常规文本的一个字符串在第二行中、常规文本的一个字符串在第三行中。 ToastImageAndText04 = 3, // // 摘要: // 包装在三行文本中的单个字符串。 ToastText01 = 4, // // 摘要: // 第一行中加粗文本的一个字符串、覆盖第二行和第三行的常规文本的一个字符串。 ToastText02 = 5, // // 摘要: // 覆盖第一行和第二行的加粗文本的一个字符串。第三行中常规文本的一个字符串。 ToastText03 = 6, // // 摘要: // 第一行中加粗文本的一个字符串、第二行中常规文本的一个字符串、第三行中常规文本的一个字符串。 ToastText04 = 7, }调用页面中的另一个方法:
void DisplayTextToastWithStringManipulation(ToastTemplateType templateType) { string toastXmlString = String.Empty; if (templateType == ToastTemplateType.ToastText01) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='ToastText01'>" + "<text id='1'>Body text that wraps over three lines</text>" + "</binding>" + "</visual>" + "</toast>"; } else if (templateType == ToastTemplateType.ToastText02) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='ToastText02'>" + "<text id='1'>Heading text</text>" + "<text id='2'>Body text that wraps over two lines</text>" + "</binding>" + "</visual>" + "</toast>"; } else if (templateType == ToastTemplateType.ToastText03) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='ToastText03'>" + "<text id='1'>Heading text that is very long and wraps over two lines</text>" + "<text id='2'>Body text</text>" + "</binding>" + "</visual>" + "</toast>"; } else if (templateType == ToastTemplateType.ToastText04) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='ToastText04'>" + "<text id='1'>Heading text</text>" + "<text id='2'>First body text</text>" + "<text id='3'>Second body text</text>" + "</binding>" + "</visual>" + "</toast>"; } Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument(); toastDOM.LoadXml(toastXmlString); ToastNotification toast = new ToastNotification(toastDOM); ToastNotificationManager.CreateToastNotifier().Show(toast); }