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 = "1";
5)可更新或删除通知(可删除某一组)
ToastNotificationManager.History.RemoveGroup("One");
转载于:https://www.cnblogs.com/xiaoshi3003/p/3764507.html
Windows Phone 8.1 Tiles, Notifications and Action Center相关推荐
- 服务器显示器出现actions,微软已修复Win10中Action Center显示在屏幕左侧问题
原标题:微软已修复Win10中Action Center显示在屏幕左侧问题 [PConline资讯]在我们等待微软重启Windows10October2018更新推送的同时,微软正通过发布预览版更新的 ...
- 连续对焦 auto对焦_如何在Windows 10上使用对焦辅助(请勿打扰模式)
连续对焦 auto对焦 Windows 10's "Focus Assist" feature is a "Do Not Disturb" mode that ...
- 辅助 已禁用 ft 55%_如何禁用Windows 10的烦人的焦点辅助通知
辅助 已禁用 ft 55% Windows 10's Focus Assist feature automatically hides notifications while you're playi ...
- Windows7安全体验
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 一.前言 ...
- 禁用内置键盘_如何禁用Windows 10的所有内置广告
禁用内置键盘 Windows 10 has a lot of built-in advertising. This isn't just about the free upgrade offer: E ...
- 一起谈.NET技术,Silverlight实例教程 - Out of Browser的Debug和Notifications窗口
Silverlight 实例教程索引 Silverlight 实例教程 - Out of Browser开篇 Silverlight 实例教程 - Out of Browser配置,安装和卸载 Sil ...
- Windows 10的下一个更新将在您观看视频时隐藏通知
Windows 10's Focus Assist feature temporarily hides incoming notifications. In Windows 10's next upd ...
- 推荐微软Windows 8 Metro应用开发虚拟实验室
Kevin Fan分享开发经验,记录开发点滴 推荐微软Windows 8 Metro应用开发虚拟实验室 2012-07-19 05:23 by jv9, 1940 阅读, 4 评论, 收藏, 编辑 微 ...
- 如何在Windows 10中打开设置?
Windows 10 provides the Windows Settings in order to configure different settings of the Windows 10. ...
最新文章
- 5G 对无线通讯芯片产业链的影响
- 第二章 微服务网关基础组件 - zuul入门
- 开发检测MySQL主从同步插件
- Goland实现Set操作
- SQL 2008升级SQL 2008 R2完全教程或者10.00.1600升级10.50.1600
- 终于搞明白gluPerspective和gluLookAt的关系了
- java hql多条件查询_Hibernate结合JPA编写通用泛型多条件查询
- java写入文件的几种方法分享
- 硬盘常规测试软件解析
- 喵哈哈村的魔法考试 Round #1 (Div.2) C 喵哈哈村的魔法石(II) 背包dp
- mysql的导入导出命令_mysql导入导出命令
- Python for Informatics 第11章 正则表达式五(译)
- 微信宣布:被禁 8 年的限制解除了!
- TurboMail邮件系统提醒广大用户小心DXXD勒索邮件
- 一系列自动化测试的开源项目介绍
- python的label属性_python内置GUI库tkinter——Label类属性
- 新浪微相册https外链图片无法调用解决方法
- 关于c基础实现简易计算器的代码(加减乘除)
- 【毕业设计】基于spring boot的图书管理系统 -java 计算机 软件工程
- 一个人最多能考取几个教师资格证?