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

  1. 使用 Windows10 自定义交互消息通知

    消息通知是最常用的应用功能之一了,但是由于平台的差异,IOS Android 以及 Windows 都有其特殊性,Android开发者在国内常常都是使用三方的一些推送服务,或者是使用自建的服务器为应用 ...

  2. windows快捷命令修炼

    Description Windows Key combination Open/Close the Start Menu Windows key Open the Action center. Wi ...

  3. 06、Windows 10 技术预览

    随着 Windows 10 发布的,未来 Windows 平台都是统一开发模型,可以只写一个 Appx 包,就可以同时部署到 Windows/ Windowsw Phone/ Tablet /xbox ...

  4. 推荐微软Windows 8 Metro应用开发虚拟实验室

    Kevin Fan分享开发经验,记录开发点滴 推荐微软Windows 8 Metro应用开发虚拟实验室 2012-07-19 05:23 by jv9, 1940 阅读, 4 评论, 收藏, 编辑 微 ...

  5. Windows Phone 8.1低功耗蓝牙开发-Nokia Treasure Tag

    1. 引言 上一篇文章<Windows 8.1 低功耗蓝牙开发>讲述了如何在Windows 8.1平台上创建低功耗蓝牙应用,并且以TI的Sensor Tag为例,给出了代码步骤和演示.其实 ...

  6. [多图]Windows 10 Build 10565今推送:优化界面菜单 Cortana改进

    酷站网软:此前的Windows Build 10558并没有向公众发布,而是直到近日才向Fast Ring用户推送了更多功能和改进的Build 10565版.除之前版本上的加入了Messaging.E ...

  7. 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 ...

  8. [No0000197]Windows用户都应该知道的运行命令

    通过"运行"命令,运行Windows丰富工具的方法.如果您知道工具或任务的相应"运行"命令,那么您就知道访问所述工具或任务的最快方法. 以下是我们最喜欢的Run ...

  9. Windows Phone 8.1 学习之路

    前几天看一哥们写的“Android学习之路”一文很不错,遂也写一篇Windows Phone的学习之路. 开发环境 台式机 不管是台式机还是笔记本,建议配置在I5+8G以上,I3+4G的话就别考虑用模 ...

随机推荐

  1. CentOS 7 网络配置、远程访问

    网络配置(配置固定IP访问) 相关命令 ip add 查看网卡状态 ifup eth0 打开端口eth0 ifdown eth0 关闭端口eth0 dhclient 自动获取IP mii-tool e ...

  2. chocolatey 的安装与安装过程中的注意事项

    安装的windows需求 Windows 7+ / Windows Server 2003+ PowerShell v2+ .NET Framework 4+   注意:chocolatey的网站可能 ...

  3. Rotation--控件位置旋转

    今天想要完成一个按钮的动画,也就是随着手势在屏幕上的滑动,让按钮图片跟着旋转.刚开始的思路是,先把图片旋转以后,在把这个图片设置为imagebutton的背景.不过,会发现这个图片经过处理以后一直变形 ...

  4. .less为后缀的文件是什么

    .less为后缀的文件是什么 一.总结 1.less是什么:LESS 为 Web 开发者带来了福音,它在 CSS 的语法基础之上,引入了变量,Mixin(混入),运算以及函数等功能,大大简化了 CSS ...

  5. vsphere client 参数

    转自:http://blog.163.com/sword_111/blog/static/66589416201422964544918/ C:\Program Files (x86)\VMware\ ...

  6. 2015,我的投资理财策略(股权众筹+P2P网贷+活期理财)

    纸币流行,尤其是当今中国的市场经济,纸币几乎是一直是贬值的,每个人的财富都在被不断地稀释,可能是被政府.如果你不注意保值增值,你就越来越穷.     当年的万元户,在今天看来就是一个笑话,其实不怎么好 ...

  7. (7)Launcher3客制化之,改动单屏幕后,Fix在Hotseat拖动应用删除报错

    改动单屏幕后,在workspace里面拖动图标.到删除button上松开的时候,报错问题. 而且无法再次显示拖动的图标. 拖动松开手时候触发 public void onDropCompleted(f ...

  8. 关于Altium Designer的BOM,元件清单

    在生成BOM列表的时候,要记得调整BOM的表格的宽度,以免显示不全, 还有就是BOM列表一共有 comment栏 ,description栏,designator栏,footprint栏,libref ...

  9. LA-3708 - Graveyard 简单的模拟一下即可

    一开始不知道在想啥,竟然写了个双重for循环的.T T一直WA,又没效率. T T然后在纸上模拟演算,改了,就AC了 以后做题果断要先模拟一下例子...能加深对题目的理解. 当教训吧..太懒导致写了好 ...

  10. 源码笔记---MBProgressHUD

    前言 作为初学者,想要快速提高自己的水平,阅读一些优秀的第三方源代码是一个非常好的途径.通过看别人的代码,可以学习不一样的编程思路,了解一些没有接触过的类和方法. MBProgressHUD是一个非常 ...