我在Package.appxmanifest中保留了ToastCapable =“true”,即便这样也没有显示吐司通知,可以从这里下载示例应用
https://docs.google.com/file/d/0B75nbNO58O7dQzM2bTloR0pia00/edit
try
{
var notificationxml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
var toastele = notificationxml.GetElementsByTagName("text");
toastele[0].AppendChild(notificationxml.CreateTextNode("this"));
var toastnote = new ToastNotification(notificationxml);
ToastNotificationManager.CreateToastNotifier().Show(toastnote);
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/10-XAML-CatImageSmall.png");
((XmlElement)toastImages[0]).SetAttribute("alt", "Scary Cat Face");
ToastNotification toast = new ToastNotification(toastXML);
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
catch (Exception msg)
{
//userprogress.Visibility = Visibility.Collapsed;
string er = msg.ToString();
var s = msg.Message;
}
请帮帮我
代码下载:https://docs.google.com/file/d/0B75nbNO58O7dQzM2bTloR0pia00/edit
答案 0 :(得分:2)
Toast仅在本地计算机中不在Stimulator中工作