好吧,我在8.1 SL項目中使用新的ToastNotificationManager而不是舊的ShellToast。 ShellToast在Toast消息上有NavigationUri,這使得它非常容易。Windows Phone 8.1中的Toast通知參數Silverlight
在新的敬酒中,您必須根據this文章自行指定啓動參數。然而它似乎像8.1 SL沒有事件OnLaunched(LaunchActivatedEventArgs參數)你應該在App.xaml.cs爲監聽的參數:
步驟2:處理應用程序的「OnLaunched」事件
當用戶點擊您的麪包片或通過觸摸選擇它時,會啓動 關聯的應用程序,從而啓動其OnLaunched事件。
注意如果不包括髮射屬性字符串在祝酒詞 和您的應用程序已經運行選擇敬酒時,該 OnLaunched事件不被解僱。
此示例顯示了覆蓋OnLaunched的事件的語法,您將在其中檢索並處理通過Toast通知提供的啓動字符串 。
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
string launchString = args.Arguments
....
}
我的代碼:
// Using the ToastText02 toast template.
ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
// Retrieve the content part of the toast so we can change the text.
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
//Find the text component of the content
XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
// Set the text on the toast.
// The first line of text in the ToastText02 template is treated as header text, and will be bold.
toastTextElements[0].AppendChild(toastXml.CreateTextNode("Heading"));
toastTextElements[1].AppendChild(toastXml.CreateTextNode("Body"));
// Set the duration on the toast
IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
((XmlElement)toastNode).SetAttribute("duration", "long");
//Launch params
string paramString = "{\"type\":\"toast\",\"param1\":\"12345\"}";
((XmlElement)toastXml.SelectSingleNode("/toast")).SetAttribute("launch", paramString);
// Create the actual toast object using this toast specification.
ToastNotification toast = new ToastNotification(toastXml);
// Set SuppressPopup = true on the toast in order to send it directly to action center without
// producing a popup on the user's phone.
toast.SuppressPopup = true;
// Send the toast.
ToastNotificationManager.CreateToastNotifier().Show(toast);
任何人知道如何解決這個問題? 謝謝
您可以直接爲烤麪包提供導航參數。當我明天回去工作時,我會得到細節。奇怪的是,我們沒有正確記錄這一點。 –
感謝您的期待! :) – robertk
如果您在Silverlight 8.1中使用ToastNotificationManager,那麼您使用的是什麼而不是OnLoaded事件,因爲SL在App.xaml中沒有該事件?我把它放在OnNavigatedTo中,但是當點擊吐司時它似乎調用了兩次我在下面的加載觸發器中使用了答案。 – gcoleman0828