【发布时间】:2016-02-17 07:33:21
【问题描述】:
我正在尝试在 Xamarin Forms、windows phone 8.1 silverlight 项目中显示 toast 通知。在 Windows Phone 项目中,我有一个创建 toast 通知的方法,但是在执行时没有任何反应。没有抛出任何错误,一切似乎都正确执行,但手机上没有任何反应。
我已经在模拟器和实际手机上对其进行了测试。到目前为止,我在网上找到的所有内容都与我所拥有的几乎相同(略有不同,但没有什么不同)。
方法中的代码如下:
private void CreateNotification(string title, string message)
{
ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
toastTextElements[0].AppendChild(toastXml.CreateTextNode(title));
toastTextElements[1].AppendChild(toastXml.CreateTextNode(message));
ToastNotification toast = new ToastNotification(toastXml);
toast.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(5);
toastNotifier.Show(toast);
}
任何帮助将不胜感激。
提前致谢!
【问题讨论】:
标签: notifications xamarin.forms toast win-phone-silverlight-8.1