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的话就别考虑用模 ...
随机推荐
- RelativeLayout-属性大全
// 相对于给定ID控件 <!--将该控件的底部置于给定ID的控件之上--> android:layout_above <!--将该控件的底部置于给定ID的控件之下--> an ...
- Mahout项目开发环境搭建(Eclipse\MyEclipse + Maven)
继续 http://www.tuicool.com/articles/rmiEz2 http://www.cnblogs.com/jchubby/p/4454888.html
- python学习一,python基本语法
python基本语法: 1.python基本语句结构: 首先,在其他的语言中,比如java,c++,c#等,没写完一行语句之后,都需要在语句的末尾加一个分号,表示该语句结束,但是在python中,我们 ...
- Mac 终端操作数据库
名词解释: 事务:一个事务(transaction)中的所有操作,要么全部完成,要么全部不完成,不会结束在中间某个环节.事务在执行过程中发生错误,会被回滚(Rollback)到事务开始前的状态,就像这 ...
- 四、Docker+Tomcat
原文:四.Docker+Tomcat 一.下载Tomcat镜像 具体可以search 搜索tomcat 相关镜像 docker pull sonodar/jdk8-tomcat8 二.创建容器 doc ...
- 【2017 Multi-University Training Contest - Team 7】Kolakoski
[Link]:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1011&cid=765 [Description] 有一种 ...
- 1、DOM4J简介
1.DOM4J简介 DOM4J是 dom4j.org 出品的一个开源 XML 解析包.DOM4J应用于 Java 平台,采用了 Java 集合框架并完全支持 DOM,SAX 和 JAXP. DOM4J ...
- lighttpd + php for android 安卓上的WEB服务器
lighttpd + php for android 安卓上的WEBSER 这个项目在 http://hex.ro/wp/blog/php-and-lighttpd-for-android 目前不支持 ...
- 22. Spring Boot 动态数据源(多数据源自动切换)
转自:https://blog.csdn.net/catoop/article/details/50575038
- subline Text3 安装及汉化
因为自己的subline 有问题 所以决心重新改一下了. 三步: http://www.sublimetext.com/3 官网下载subline3 https://www.imjeff. ...