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的更多相关文章

  1. Kinect for Windows SDK v2.0 开发笔记 (十五) 手势帧

     (转载请注明出处) 使用SDK: Kinect for Windows SDK v2.0 public preview1409 同前面,由于SDK未完毕,不附上函数/方法/接口的超链接. 这次最 ...

  2. windows phone 8.1开发:锁屏提醒

    原文出自:http://www.bcmeng.com/lockscreen/ 之前小梦和大家分享了toast通知,磁铁更新,今天小梦和大家分享windows phone 8.1开发中的锁屏提醒.相比t ...

  3. [笔记] C# Windows Phone 8 WP8 开发,判断目前网路是否可用。

    原文:[笔记] C# Windows Phone 8 WP8 开发,判断目前网路是否可用. 常常我们在开发Windows Phone 8 App时会使用网路来读取网页的资料或其他开放平台的Json.X ...

  4. Windows 8.1 store app 开发笔记

    原文:Windows 8.1 store app 开发笔记 零.简介 一切都要从博彦之星比赛说起.今年比赛的主题是使用Bing API(主要提到的有Bing Map API.Bing Translat ...

  5. FFmpeg开发笔记(三):ffmpeg介绍、windows编译以及开发环境搭建

    前言   本篇章是对之前windows环境的补充,之前windows的是无需进行编译的,此篇使用源码进行编译,版本就使用3.4.8.   FFmpeg简介   FFmpeg是领先的多媒体框架,能够解码 ...

  6. zlib开发笔记(四):zlib库介绍、编译windows vs2015x64版本和工程模板

    前言   Qt使用一些压缩解压功能,介绍过libzip库编译,本篇说明zlib库.需要用到zlib的msvc2015x64版本,编译一下.   版本编译引导 zlib在windows上的mingw32 ...

  7. [开发笔记]-控制Windows Service服务运行

    用代码实现动态控制Service服务运行状态. 效果图: 代码: #region 启动服务 /// <summary> /// 启动服务 /// </summary> /// ...

  8. [转]Windows平台下Makefile学习笔记

    Windows平台下Makefile学习笔记(一) 作者:朱金灿 来源:http://blog.csdn.net/clever101 决心学习Makefile,一方面是为了解决编译开源代码时需要跨编译 ...

  9. [开发笔记]-未找到与约束ContractName Microsoft.VisualStudio.Text.ITextDocumentFactoryService...匹配的导出【转载自:酷小孩】

    原文地址:http://www.cnblogs.com/babycool/p/3199158.html 今天打算用VisualStudio2012做一个js效果页面测试的时候,打开VS2012新建项目 ...

随机推荐

  1. c语言将2进制数转化为10进制数(栈的初始化,进栈,出栈)

    //c语言描述 将2进制转化为10进制 #include <stdio.h> #include <stdlib.h> #include <math.h> #defi ...

  2. 学习总结 html图片热点,网页划区,拼接,表单

    表单: action="负责处理的 <form id="" name="" method="post/get"服务端&quo ...

  3. 学习总结 vs软件简单了解

    using System;using System.Collections.Generic;using System.Linq;using System.Text;//调用命名空间 using Sys ...

  4. javascript代码复用模式(二)

    前面说到,javascript的代码复用模式,可分为类式继承和非类式继承(现代继承).这篇就继续类式继承. 类式继承模式-借用构造函数 使用借用构造函数的方法,可以从子构造函数得到父构造函数传任意数量 ...

  5. C#中DataTable转换JSON

    #region 将DataTable转换为json public string dt2json(DataTable dt) { JavaScriptSerializer jss = new JavaS ...

  6. python md5

    import hashlib import os 简单的测试一个字符串的MD5值 src = 'teststring' print (hashlib.md5(src).hexdigest().uppe ...

  7. javascript 同步加载与异步加载

    HTML 4.01 的script属性 charset: 可选.指定src引入代码的字符集,大多数浏览器忽略该值. defer: boolean, 可选.延迟脚本执行,相当于将script标签放入页面 ...

  8. C# 发送邮件方法2

    一. 发送邮件程序:(使用System.Web.Mail下的类) "; //SMTP服务密码 strFrom = "jailu@163.com"; //发送方邮件地址 C ...

  9. sublineText

    https://github.com/thinkpixellab/flatland { "color_scheme": "Packages/Theme - Flatlan ...

  10. svn服务端配置

    1.建立版本库 创建一个新的Subversion项目svnadmin create /var/www/svndata/njlrxx 配置允许用户jiqing访问cd /var/www/svndata/ ...