windows phone 8.1开发笔记之Toast
Toast(吐司)是wp屏幕上端弹出来的临时通知,他会存在7秒钟的时间,可以快速定位到用户需要的位置(当然是由开发者设置的)
1.创建一个Toast
now,需要将你的app设置支持Toast 否则即使你写好了,他也是不工作的 。
应用程序清单里面直接选择就OK了。

然后看一段代码示例:
public void ToastNotification()
{
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
XmlNodeList elements = toastXml.GetElementsByTagName("text");
elements[].AppendChild(toastXml.CreateTextNode("第一个土司"));
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
在你需要的地方调用:
private void Button_Click(object sender, RoutedEventArgs e)
{
ToastNotification();
}
Ok,你就可以体验Toast啦!
2:Toast的过程
由上不难看出,创建一个头Toast需要4步,1-创建Toast通知模板。2-添加Toast内容。3-创建Toast通知对象。4-弹出通知
3:定期通知
有的时间我们需要的是定时通知,程序可以使后台运行运行时,这个时候就要用ScheduledToastNotification了,示例代码:
private void ToastNotification1()
{
//ScheduledToastNotification
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
toastNodeList.Item().AppendChild(toastXml.CreateTextNode("Toast Title"));
toastNodeList.Item().AppendChild(toastXml.CreateTextNode("Toast Content"));
DateTime startTime = DateTime.Now.AddSeconds();
ScheduledToastNotification recurringToast = new ScheduledToastNotification(toastXml, startTime);
recurringToast.Id = "Scheduled1";
ToastNotificationManager.CreateToastNotifier().AddToSchedule(recurringToast);
}
注意:要加入到构造函数中的哈
windows phone 8.1开发笔记之Toast的更多相关文章
- Kinect for Windows SDK v2.0 开发笔记 (十五) 手势帧
(转载请注明出处) 使用SDK: Kinect for Windows SDK v2.0 public preview1409 同前面,由于SDK未完毕,不附上函数/方法/接口的超链接. 这次最 ...
- windows phone 8.1开发:锁屏提醒
原文出自:http://www.bcmeng.com/lockscreen/ 之前小梦和大家分享了toast通知,磁铁更新,今天小梦和大家分享windows phone 8.1开发中的锁屏提醒.相比t ...
- [笔记] C# Windows Phone 8 WP8 开发,判断目前网路是否可用。
原文:[笔记] C# Windows Phone 8 WP8 开发,判断目前网路是否可用. 常常我们在开发Windows Phone 8 App时会使用网路来读取网页的资料或其他开放平台的Json.X ...
- Windows 8.1 store app 开发笔记
原文:Windows 8.1 store app 开发笔记 零.简介 一切都要从博彦之星比赛说起.今年比赛的主题是使用Bing API(主要提到的有Bing Map API.Bing Translat ...
- FFmpeg开发笔记(三):ffmpeg介绍、windows编译以及开发环境搭建
前言 本篇章是对之前windows环境的补充,之前windows的是无需进行编译的,此篇使用源码进行编译,版本就使用3.4.8. FFmpeg简介 FFmpeg是领先的多媒体框架,能够解码 ...
- zlib开发笔记(四):zlib库介绍、编译windows vs2015x64版本和工程模板
前言 Qt使用一些压缩解压功能,介绍过libzip库编译,本篇说明zlib库.需要用到zlib的msvc2015x64版本,编译一下. 版本编译引导 zlib在windows上的mingw32 ...
- [开发笔记]-控制Windows Service服务运行
用代码实现动态控制Service服务运行状态. 效果图: 代码: #region 启动服务 /// <summary> /// 启动服务 /// </summary> /// ...
- [转]Windows平台下Makefile学习笔记
Windows平台下Makefile学习笔记(一) 作者:朱金灿 来源:http://blog.csdn.net/clever101 决心学习Makefile,一方面是为了解决编译开源代码时需要跨编译 ...
- [开发笔记]-未找到与约束ContractName Microsoft.VisualStudio.Text.ITextDocumentFactoryService...匹配的导出【转载自:酷小孩】
原文地址:http://www.cnblogs.com/babycool/p/3199158.html 今天打算用VisualStudio2012做一个js效果页面测试的时候,打开VS2012新建项目 ...
随机推荐
- struts2拦截器拦截成功后每次请求都出现拦截时的错误信息
action中验证方法 在执行execute之前执行 @Override public void validate() { // TODO Auto-generated metho ...
- ASP.NET MVC学习1
ViewBag是一个dynamic(动态类型)类型集合,可以动态添加任何类型的任意名称的属性和值,ViewBag是Controller和view之间传递数据的,如以下: ViewBag.HtmlStr ...
- @media screen解决移动web开发的多分辨率问题
当今移动设备的发展已经越来越迅速,移动web开发的需求也越来越多多.许多大平台.大门户都纷纷推出了自己的移动web版网站. 随着移动设备飞速的发展,移动产品的屏幕规格越来越多.从几年前的320×240 ...
- DEDECMS自动编号(序号)autoindex属性
让织梦dedecms autoindex,itemindex 从0到1开始的办法! 1 2 3 [field:global name=autoindex runphp="yes"] ...
- Git入门详解
查看分支:git branch 创建分支:git branch <name> 切换分支:git checkout <name> 创建+切换分支:git checkout -b ...
- JS常用的设计模式(7)—— 外观模式
外观模式(门面模式),是一种相对简单而又无处不在的模式.外观模式提供一个高层接口,这个接口使得客户端或子系统更加方便调用.用一段再简单不过的代码来表示 var getName = function() ...
- Windows USN Journal Parsing
What is "USN Journal"? It is "Update Sequence Number Journal". It records change ...
- Dell™ SAS 5/iR 集成适配器和适配器用户指南
http://www.sxszjzx.com/~t096/manual/sc/SAS_5ir/index.htm
- projecteuler Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any rema ...
- Linux FTP服务器搭建与使用
一.vsftpd说明 LINUX下实现FTP服务的软件很多,最常见的有vsftpd,Wu-ftpd和Proftp等.Red Hat Enterprise Linux中默认安装的是vsftpd. 访问F ...