ToastTemplateType toastType = ToastTemplateType.ToastImageAndText02;
XmlDocument toastXML = ToastNotificationManager.GetTemplateContent(toastType);
XmlNodeList toastText = toastXML.GetElementsByTagName("text");
XmlNodeList toastImages = toastXML.GetElementsByTagName("image");
toastText[0].InnerText = "Funny cat";
toastText[1].InnerText = "This cat looks like it's trying to eat your face.";
((XmlElement)toastImages[0]).SetAttribute("src", "ms-appx:///Assets/washer.png");
((XmlElement)toastImages[0]).SetAttribute("alt", "Scary Cat Face");
//This is the options code, which is all optional based on your needs.
IXmlNode toastNode = toastXML.SelectSingleNode("/toast");
((XmlElement)toastNode).SetAttribute("duration", "long");
XmlElement audioNode = toastXML.CreateElement("audio");
audioNode.SetAttribute("src", "ms-appx:///Assets/beep.wav");
//Must be used when looping audio has been selected.
audioNode.SetAttribute("loop", "true");
toastNode.AppendChild(audioNode);
//You can append any text data you would like to the optional
//launch property, but clicking a Toast message should drive
//the user to something contextually relevant.
((XmlElement)toastNode).SetAttribute("launch", "<cat state='angry'><facebite state='true' /></cat>");
ToastNotification toast = new ToastNotification(toastXML);
ToastNotificationManager.CreateToastNotifier().Show(toast);
所以我从网页上获取了这段代码,它可以工作,但有一个细节。它播放的声音不是我想要它播放的声音...即使指定名称和资产,它看起来像是播放来自微软的声音?谢谢!