Windows Phone 8.1 Tiles, Notifications and Action Center
(1)Tiles
Tiles 也就是磁贴,是 Windows Phone 的一大特色。
一个 Tile 其实可以看成是一个 XML,比如:
<tile>
<visual>
<binding template="TileSquareImage">
<image id="1" src="data:image1" alt="alt text"/>
</binding>
</visual>
</tile> <tile>
<visual version="2">
<binding template="TileSquare150x150Image" fallback="TileSquareImage">
<image id="1" src="data:image1" alt="alt text"/>
</binding>
</visual>
</tile>
微软为我们提供了一系列模板,具体可参照:链接
只要根据模板的 XML 格式,便可轻松的更新 Tile:
private void updateButton_Click(object sender, RoutedEventArgs e)
{
UpdateTiles("ms-appx:///Images/Middle.png", "ms-appx:///Images/Wide.png");
} private void UpdateTiles(string middlePath, string widePath)
{
string tileString = "<tile>" +
"<visual version=\"2\">" +
"<binding template=\"TileSquare150x150PeekImageAndText04\" fallback=\"TileSquarePeekImageAndText04\">" +
"<image id=\"1\" src=\"" + middlePath + "\" alt=\"alt text\"/>" +
"<text id=\"1\"></text>" +
"</binding>" +
"<binding template=\"TileWide310x150ImageAndText01\" fallback=\"TileWideImageAndText01\">" +
"<image id=\"1\" src=\"" + widePath + "\" alt=\"alt text\"/>" +
"<text id=\"1\"></text>" +
"</binding>" +
"</visual>" +
"</tile>";
XmlDocument tileXML = new XmlDocument();
tileXML.LoadXml(tileString); TileNotification newTile = new TileNotification(tileXML);
TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication();
updater.EnableNotificationQueue(false);
updater.Update(newTile);
}
除了主磁贴外我们还可以新建 SecondaryTile:
private void createButton_Click(object sender, RoutedEventArgs e)
{
CreateTile("ms-appx:///Images/Middle.png", "ms-appx:///Images/Wide.png");
} private async void CreateTile(string middlePath, string widePath)
{
SecondaryTile tile = new SecondaryTile("Cortana", "Cortana", "Some", new Uri(middlePath), TileSize.Default);
tile.VisualElements.ShowNameOnSquare150x150Logo = true;
tile.VisualElements.ForegroundText = ForegroundText.Dark;
tile.VisualElements.Square30x30Logo = new Uri(middlePath);
tile.VisualElements.Wide310x150Logo = new Uri(widePath);
await tile.RequestCreateAsync();
}
SecondaryTile 的更新与主磁贴更新一样:
TileUpdater update = TileUpdateManager.CreateTileUpdaterForSecondaryTile("Cortana");
(2)Notifications
Notification(推送通知)分为 Tile,Badge,Toast,Raw 四种类型,而通知的方式又分为 Scheduled,Periodic,Local,Push 四种,它们之间对应的关系为:
使用方法都大同小异,根据各自的 XML 格式修改再调用 Update 方法即可,例如:
XmlDocument xml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText04);
ToastNotification toast = new ToastNotification(xml);
ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
notifier.Show(toast);
需要注意的是:(1)Toast 通知需要在 Manifest 中许可;(2)Push 方法为:
private async void SendRawNotification()
{
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
channel.PushNotificationReceived += channel_PushNotificationReceived;
} private void channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
{
var raw = args.RawNotification;
}
(3)Action Center
1)每个应用最多可以在 Action Center 中驻留 20 条通知
2)通知最多可驻留 7 天
3)可发送静默通知(不会提示用户)
toast1.SuppressPopup = true;
4)可对通知进行分组
XmlDocument xml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText04); ToastNotification toast1 = new ToastNotification(xml);
toast1.Group = "One";
toast1.Tag = "";
5)可更新或删除通知(可删除某一组)
ToastNotificationManager.History.RemoveGroup("One");
Windows Phone 8.1 Tiles, Notifications and Action Center的更多相关文章
- 使用 Windows10 自定义交互消息通知
消息通知是最常用的应用功能之一了,但是由于平台的差异,IOS Android 以及 Windows 都有其特殊性,Android开发者在国内常常都是使用三方的一些推送服务,或者是使用自建的服务器为应用 ...
- windows快捷命令修炼
Description Windows Key combination Open/Close the Start Menu Windows key Open the Action center. Wi ...
- 06、Windows 10 技术预览
随着 Windows 10 发布的,未来 Windows 平台都是统一开发模型,可以只写一个 Appx 包,就可以同时部署到 Windows/ Windowsw Phone/ Tablet /xbox ...
- 推荐微软Windows 8 Metro应用开发虚拟实验室
Kevin Fan分享开发经验,记录开发点滴 推荐微软Windows 8 Metro应用开发虚拟实验室 2012-07-19 05:23 by jv9, 1940 阅读, 4 评论, 收藏, 编辑 微 ...
- Windows Phone 8.1低功耗蓝牙开发-Nokia Treasure Tag
1. 引言 上一篇文章<Windows 8.1 低功耗蓝牙开发>讲述了如何在Windows 8.1平台上创建低功耗蓝牙应用,并且以TI的Sensor Tag为例,给出了代码步骤和演示.其实 ...
- [多图]Windows 10 Build 10565今推送:优化界面菜单 Cortana改进
酷站网软:此前的Windows Build 10558并没有向公众发布,而是直到近日才向Fast Ring用户推送了更多功能和改进的Build 10565版.除之前版本上的加入了Messaging.E ...
- I Take It All Back: Using Windows Installer (MSI) Rollback Actions
Original Link: http://blogs.flexerasoftware.com/installtalk/2011/10/i-take-it-all-back-using-windows ...
- [No0000197]Windows用户都应该知道的运行命令
通过"运行"命令,运行Windows丰富工具的方法.如果您知道工具或任务的相应"运行"命令,那么您就知道访问所述工具或任务的最快方法. 以下是我们最喜欢的Run ...
- Windows Phone 8.1 学习之路
前几天看一哥们写的“Android学习之路”一文很不错,遂也写一篇Windows Phone的学习之路. 开发环境 台式机 不管是台式机还是笔记本,建议配置在I5+8G以上,I3+4G的话就别考虑用模 ...
随机推荐
- javascript进阶课程--第二章--对象
javascript进阶课程--第二章--对象 学习要点 理解面向对象的概念 掌握对象的创建方法 掌握继承的概念和实现方法 基本概念 对象究竟是什么?什么叫面向对象编程? 对象是从我们现实生活中抽象出 ...
- 2. APIS官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ 2. APIS .APIS Apache Kafka引入一个新的java客户端(在o ...
- modal模态框插件
用法: <!--模态框--> <div class="modal fade" id="myModal"> <div class=& ...
- golang excel
github.com/tealeg/xlsx 封装的接口简单易用 package main import ( "bufio" "fmt" "githu ...
- Robot Framework 自动化测试
Robot Framework 自动化测试 RIDE 是 Robot Framework 测试数据的编辑器.它使测试用例的创建.运行.测试项目的组织可以在图形界面下完成. 通过 RIDE 去学习和使用 ...
- 51NOD——T 1079 中国剩余定理
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1079 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难 ...
- 洛谷 P1100 高低位交换
P1100 高低位交换 题目描述 给出一个小于2^32的正整数.这个数可以用一个32位的二进制数表示(不足32位用0补足).我们称这个二进制数的前16位为“高位”,后16位为“低位”.将它的高低位交换 ...
- 【Todo】Zookeeper系列文章
http://nileader.blog.51cto.com/1381108/1068033
- [React] Style the body element with styled-components and "injectGlobal"
In this lesson, we see how we can apply styles globally with the "injectGlobal" helper met ...
- Git 基本使用方法
Git有一个优点,在本地的每个项目都是一个完整的仓库,除了须要从网络拉取和推送到网络之外,其它全部的操作都能够在本地完毕. 本文简单地介绍怎样在本地使用Git来对文件进行管理,下一篇文章再来说一下分支 ...