Windows RT和Toast通知行为(Windows RT and Toast Notification behavior)

编程入门 行业动态 更新时间:2024-10-24 13:18:10
Windows RT和Toast通知行为(Windows RT and Toast Notification behavior)

你好, 我正在测试Windows RT应用程序的Toast Notification。 我在清单文件上将'Toast Capable'设置为yes,并创建一个由按钮调用的示例方法,其代码为:

var toastTemplate = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText01);

var text = toastTemplate.GetElementsByTagName(“text”)[0] as XmlElement; text.AppendChild(toastTemplate.CreateTextNode(“这是测试!”));

var image = toastTemplate.GetElementsByTagName(“image”)[0] as XmlElement; image.SetAttribute(“src”,String.Format(“ms-appx:/// {0}”,“Images / rss_logo.png”));

ToastNotification toastNotification = new ToastNotification(toastTemplate); ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier(); toastNotifier.Show(toastNotification);

当我点击按钮时,通知显示在屏幕的右上角,但没有文字和图像......只是带有应用程序徽标的框。

你能告诉我我哪里错了吗? 谢谢你的帮助。

Hello, I'm testing the Toast Notification for a Windows RT application. I set the 'Toast Capable' to yes on the manifest file, and I create a sample method called by a button, with this code Inside :

var toastTemplate = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText01);

var text = toastTemplate.GetElementsByTagName("text")[0] as XmlElement; text.AppendChild(toastTemplate.CreateTextNode("This is the test !"));

var image = toastTemplate.GetElementsByTagName("image")[0] as XmlElement; image.SetAttribute("src", String.Format("ms-appx:///{0}", "Images/rss_logo.png"));

ToastNotification toastNotification = new ToastNotification(toastTemplate); ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier(); toastNotifier.Show(toastNotification);

When I cleck the button, the notification appears on the top right of the screen, but without text and image... Just the box, with the logo of application.

Could you please tell me where I'm wrong ? Thanks for your help.

最满意答案

关于第一个问题(文本没有出现):

在清单文件'Package.manifest'中,我将Foreground文本设置为'Dark'。 问题是默认情况下,前景文本是白色的。

关于Image的问题:

我的图像格式不正确,而不是在正确的目录中。 在MS QuickStart([http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh868254(v = win.10).aspx] [1])中,它说: >“为每个图像源显示此步骤的版本。图像必须>小于200 KB且小于1024 x 1024像素。”

About the first problem (text not appear) :

In the Manifest file 'Package.manifest', I set Foreground text to 'Dark'. The problem was that by default the text Foreground is white.

The problem about Image :

My image was not in correct format, and not in the right directory. In the MS QuickStart([http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh868254(v=win.10).aspx][1]), it said: > " Versions of this step are shown for each image source. Images must > be less than 200 KB in size and smaller than 1024 x 1024 pixels. "

更多推荐

本文发布于:2023-08-07 21:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466426.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通知   RT   Windows   Toast   behavior

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!