显示本地 Toast 通知 [英] Display local toast notification

查看:23
本文介绍了显示本地 Toast 通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为 Windows Phone 8.1 开发一个包含本地通知"的通用应用.

I want to develop a universal app for Windows Phone 8.1 which contains a local "Notification".

我想要做的是在 toast 控件的扭结中向用户显示所有消息(错误、信息、警告).一切都在本地完成,无需通过标准通知系统.有几个系统可以在 Windows Phone 8 上运行:

What I want to do is to show all messages to the user (error, information, warnings) in a kink of toast control. Everything is done locally without going through the standard notification system. There are several system that work on Windows Phone 8:

但不可能在 Windows Phone 8.1 项目中包含这些库.

But it's not possible to include those libraries on windows phone 8.1 project.

有人知道另一种显示本地"吐司的方法吗?

Does anyone know another method to display "local" toasts?

推荐答案

您可以使用在您的应用运行时出现的本地通知.

You could use a local notification that appears when your app is running.

ToastTemplateType toastTemplateXml = ToastTemplateType.ToastImageAndText01; 
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplateXml);

然后您需要填充 GetTemplateContent

<toast>
    <visual>
        <binding template="ToastImageAndText01">
            <image id="img" src=""/>
            <text id="txt"></text>
        </binding>
    </visual>
</toast>

在 XML DOM 中提供 Toast 的内容.该图像仅与 Windows 8.1 相关.

Supply the content of your toast in the XML DOM. The image is relevant only for Windows 8.1.

指定它的启动参数

((XmlElement)toastNode).SetAttribute("launch", "{\"type\":\"toast\",\"param1\":\"1\",\"param2\":\"2\"}");

创建 toast 对象:

Create the toast object:

ToastNotification toast = new ToastNotification(toastXml);

最后显示吐司.

ToastNotificationManager.CreateToastNotifier().Show(toast);

另外,如果您想使用第三方控件来显示 Toast,那么您可以考虑编写一个 Windows Phone 8.1 Silverlight 应用程序.

Also, If you want to use a third party control to display the toast then you could consider writing a Windows Phone 8.1 Silverlight app.

这篇关于显示本地 Toast 通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆