我正在编写一个使用Toast通知的Windows Phone 8.1应用程序,它必须在循环中多次显示。它显示的是值,但只播放一次声音。这是代码:
while (increments <10)
{
ToastTemplateType toastType = ToastTemplateType.ToastText02;
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastType);
XmlNodeList toastTextElement = toastXml.GetElementsByTagName("text");
toastTextElement[0].AppendChild(toastXml.CreateTextNode("Time since button pressed: "));
toastTextElement[1].AppendChild(toastXml.CreateTextNode( increments+" seconds"));
IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
((XmlElement)toastNode).SetAttribute("duration", "long");
XmlElement audio = toastXml.CreateElement("audio");
audio.SetAttribute("src", "ms-appx:///Assets/N.mp3");
toastNode.AppendChild(audio);
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
increments++;
tempCounter++;
}