【发布时间】:2015-06-09 11:55:32
【问题描述】:
我使用 C# 和 Windows Phone 8.1 作为通用应用程序。我可以通过这段代码从后台发送通知:
void ShowNotification(string title, string text)
{
ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
XmlNodeList textElements = toastXml.GetElementsByTagName("text");
textElements[0].AppendChild(toastXml.CreateTextNode(title));
textElements[1].AppendChild(toastXml.CreateTextNode(text));
ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(toastXml));
}
我想当用户在操作中心点击这些通知时,我在通知中写的消息会显示在我的 MainPage 的 textBlock 上,但我不知道如何设置参数来执行此操作。我在 MainPage 中使用了此代码,但参数为空:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e != null && e.Parameter != null)
{
Debug.WriteLine("MainPage.OnNavigatedTo.Parameter: " + e.Parameter.ToString());
}
}
谢谢
【问题讨论】:
标签: c# windows-phone-8.1 win-universal-app