2
我使用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());
}
}
感谢