好吧,我在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