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的话就别考虑用模 ...
随机推荐
- elasticsearch java 客户端之Client简介
elasticsearch通过构造一个client对外提供了一套丰富的java调用接口.总体来说client分为两类cluster信息方面的client及数据(index)方面的client.这两个大 ...
- ReactJs 入门DEMO(转自别人)
附件是分享的一些他人的ReactJs入门DEMO,以前版本使用的是JSXTransformer.js,新版的用browser.min.js替代了. DEMO 下载地址:http://files.cnb ...
- 体验SUSE (附视频演示)
操作动画演示 本文出自 "李晨光原创技术博客" 博客,谢绝转载!
- BZOJ3091: 城市旅行(LCT,数学期望)
Description Input Output Sample Input 4 5 1 3 2 5 1 2 1 3 2 4 4 2 4 1 2 4 2 3 4 3 1 4 1 4 1 4 Sample ...
- python3操作Excel
1.安装openpyxl模块: 在cmd命令窗执行命令 pip install openpyxl 安装openpyxl模块 from openpyxl import load_workbook ...
- CISP/CISA 每日一题 21
CISSP 每日一题(答)What is the term that identifies data ona disk after the data has supposedly been erase ...
- Boost解析xml——xml写入
<?xml version="1.0" encoding="utf-8"?> <Config> <Item name=" ...
- 【Good Bye 2017 A】New Year and Counting Cards
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 是元音字母或者是奇数就递增. [代码] #include <bits/stdc++.h> using namespace ...
- 【Codeforces Round #428 (Div. 2) C】Journey
[Link]:http://codeforces.com/contest/839/problem/C [Description] 给一棵树,每当你到一个点x的时候,你进入x的另外一每一个出度的概率都是 ...
- [D3JS] Add more map layer and color
import React, {Component} from 'react'; import * as d3 from 'd3'; import 'd3-geo'; import * as topoj ...