(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相关推荐

  1. 服务器显示器出现actions,微软已修复Win10中Action Center显示在屏幕左侧问题

    原标题:微软已修复Win10中Action Center显示在屏幕左侧问题 [PConline资讯]在我们等待微软重启Windows10October2018更新推送的同时,微软正通过发布预览版更新的 ...

  2. 连续对焦 auto对焦_如何在Windows 10上使用对焦辅助(请勿打扰模式)

    连续对焦 auto对焦 Windows 10's "Focus Assist" feature is a "Do Not Disturb" mode that ...

  3. 辅助 已禁用 ft 55%_如何禁用Windows 10的烦人的焦点辅助通知

    辅助 已禁用 ft 55% Windows 10's Focus Assist feature automatically hides notifications while you're playi ...

  4. Windows7安全体验

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 一.前言    ...

  5. 禁用内置键盘_如何禁用Windows 10的所有内置广告

    禁用内置键盘 Windows 10 has a lot of built-in advertising. This isn't just about the free upgrade offer: E ...

  6. 一起谈.NET技术,Silverlight实例教程 - Out of Browser的Debug和Notifications窗口

    Silverlight 实例教程索引 Silverlight 实例教程 - Out of Browser开篇 Silverlight 实例教程 - Out of Browser配置,安装和卸载 Sil ...

  7. Windows 10的下一个更新将在您观看视频时隐藏通知

    Windows 10's Focus Assist feature temporarily hides incoming notifications. In Windows 10's next upd ...

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

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

  9. 如何在Windows 10中打开设置?

    Windows 10 provides the Windows Settings in order to configure different settings of the Windows 10. ...

最新文章

  1. 5G 对无线通讯芯片产业链的影响
  2. 第二章 微服务网关基础组件 - zuul入门
  3. 开发检测MySQL主从同步插件
  4. Goland实现Set操作
  5. SQL 2008升级SQL 2008 R2完全教程或者10.00.1600升级10.50.1600
  6. 终于搞明白gluPerspective和gluLookAt的关系了
  7. java hql多条件查询_Hibernate结合JPA编写通用泛型多条件查询
  8. java写入文件的几种方法分享
  9. 硬盘常规测试软件解析
  10. 喵哈哈村的魔法考试 Round #1 (Div.2) C 喵哈哈村的魔法石(II) 背包dp
  11. mysql的导入导出命令_mysql导入导出命令
  12. Python for Informatics 第11章 正则表达式五(译)
  13. 微信宣布:被禁 8 年的限制解除了!
  14. TurboMail邮件系统提醒广大用户小心DXXD勒索邮件
  15. 一系列自动化测试的开源项目介绍
  16. python的label属性_python内置GUI库tkinter——Label类属性
  17. 新浪微相册https外链图片无法调用解决方法
  18. 关于c基础实现简易计算器的代码(加减乘除)
  19. 【毕业设计】基于spring boot的图书管理系统 -java 计算机 软件工程
  20. 一个人最多能考取几个教师资格证?

热门文章

  1. tomcat中的几种log catalina localhost
  2. Pywinauto自动化操作PC微信提取好友微信号
  3. 常用的Firefox浏览器插件、Chrome浏览器插件收藏
  4. Mysql Error 1142错误解决方法
  5. Activity的跳转及返回值,activity的生命周期
  6. PHP版本的自动生成有规则的订单号(或编号)
  7. Java学习的30个目标以及系统架构师推荐的书
  8. OpenCV 车道线提取
  9. capture one 20 pro中文版
  10. WebGoat系列实验Cross-Site Scripting (XSS)