当前位置: 首页 > 编程语言 > C#

Windows Phone 8.1 Silverlight中的Toast通知参数分享

时间:2023-04-10 17:48:08 C#

C#学习教程:WindowsPhone8.1Silverlight中的Toast通知参数ShellToast在toast消息上有NavigationUri,这很容易。在新的toast中,您必须根据本文自行指定启动参数。但它看起来像8.1SL没有事件OnLaunched(LaunchActivatedEventArgsargs)你应该在App.xaml.cs中听参数:第2步:处理你的应用程序的“OnLaunched”事件当用户点击你的吐司或通过触摸选择它时,关联的应用程序将启动并触发其OnLaunched事件。请注意,如果您不在Toast中包含启动属性字符串,并且在选择Toast时您的应用程序已经在运行,则不会触发OnLaunched事件。此示例显示OverLaunched事件的覆盖语法,您可以在其中检索和处理通过Toast通知提供的启动字符串。protectedoverridevoidOnLaunched(LaunchActivatedEventArgsargs){stringlaunchString=args.Arguments....}我的代码://使用ToastText02toast模板。ToastTemplateTypetoastTemplate=ToastTemplateType.ToastText02;//检索toast的内容部分,以便我们可以更改文本。XmlDocumenttoastXml=ToastNotificationManager.GetTemplateContent(toastTemplate);//找到内容的文本组件XmlNodeListtoastTextElements=toastXml.GetElementsByTagName("text");//设置吐司上的文本。//ToastText02模板中的第一行文本被视为标题文本,并且为粗体。toastTextElements[0].AppendChild(toastXml.CreateTextNode("标题"));toastTextElements[1].AppendChild(toastXml.CreateTextNode("Body"));//在toast上设置持续时间IXmlNodetoastNode=toastXml.SelectSingleNode("/toast");((XmlElement)toastNode).SetAttribute("duration","long");//启动参数字符串paramString="{"type":"toast","param1":"12345"}";((XmlElement)toastXml.SelectSingleNode("/toast")).SetAttribute("launch",paramString);//使用此toast规范创建实际的toast对象。ToastNotificationtoast=newToastNotification(toastXml);//在toast上设置SuppressPopup=true,以便将其直接发送到操作中心,而不会//??在用户手机上产生弹出窗口。toast.SuppressPopup=true;//发送toast.ToastNotificationManager.CreateToastNotifier().Show(toast);有谁知道怎么解决这个问题吗?谢谢。你的问题是启动参数设置错误。你应该直接设置到你要导航到的页面。上面是C#学习教程:WindowsPhone8.1Silverlight如果对你有用,需要了解更多C#学习教程,希望大家多多关注—vartoastNavigationUriString=""#/MainPage.xaml?param1=12345";vartoastElement=((XmlElement)toastXml.SelectSingleNode("/toast"));toastElement.SetAttribute("启动",toastNavigationUriString);本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处: