【发布时间】:2015-05-30 06:27:41
【问题描述】:
下面的方法在调用 set Toast 时执行,但在时间过去后不显示任何 Toast。 Windows 8 Metro 应用 Toast 通知是否需要更多设置
int scheduledToastCounter = 1;
public void Set_Future_Toast()
{
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
stringElements.Item(0).AppendChild(toastXml.CreateTextNode("Scheduled Toast"));
DateTimeOffset displayTime = DateTimeOffset.UtcNow.AddSeconds(3);
ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, displayTime);
scheduledToast.Id = "Future_" + this.scheduledToastCounter++;
ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
notifier.AddToSchedule(scheduledToast);
int scheduledToastCount = notifier.GetScheduledToastNotifications().Count;
}
}
【问题讨论】:
-
空的
catch块在那里做什么?除了隐藏错误。 -
@CodyGray 我只是在这里忽略了异常处理。但是方法执行没有任何异常。
标签: windows-8 toast microsoft-metro