你好, 我正在测试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. "
更多推荐
发布评论