Windows 8技巧:Windows 8 中的Toast Tile Badge通知的使用方法
发布时间:2013-04-22 17:50:11 作者:佚名
我要评论
本篇文章小编为大家介绍,Windows 8技巧:Windows 8 中的Toast Tile Badge通知的使用方法 。需要的朋友参考下
在Windows 8中有三种通知的方式及时提醒用户,它们分别是Toast,Tile,Badge
Toast:是在应用程序中及时弹出的提醒通知。
Tile:是磁贴通知,用于Metro界面中的应用程序图标上进行图片和文字通知。
Badge:是在磁贴小贴士通知,用于Metro界面中的应用程序图标右下角提示当前有多少新消息或者当前应用程序状态,如(playing paused newMessage)等。
准备工作: 首先:引用NotificationsExtensions.winmd库,这是对各种通知简化访问的封装。
其次:打开Package.appxmanifest重新设置各种徽标。
最后:打开Package.appxmanifest,设置“支持Toast通知”为“是”。

Toast:
复制代码
代码如下:private void ToastNotice_Click(object sender, RoutedEventArgs e)
{
//Toast通知文字以及图片设置
IToastImageAndText01 Toast = ToastContentFactory.CreateToastImageAndText01();
Toast.TextBodyWrap.Text = "今日世界末日倒数10天!";
Toast.Image.Src = "http://news.shangdu.com/301/20120512/P_5626361_0__1686841290.jpg";
ToastNotificationManager.CreateToastNotifier().Show(Toast.CreateNotification());
}
效果图片:

Tile:
复制代码
代码如下:private void TileNotice_Click(object sender, RoutedEventArgs e)
{
//Tile通知文字以及图片设置
ITileWideImageAndText01 tile = TileContentFactory.CreateTileWideImageAndText01();
tile.TextCaptionWrap.Text = "小资情有独钟 10款合资热销时尚车型导购";
tile.Image.Src = "http://news.mycar168.com/uploadfile/2011/1030/20111030040816628.jpg";</p> <p> ITileSquareImage wideImageContent = TileContentFactory.CreateTileSquareImage();
wideImageContent.Image.Src = "http://news.mycar168.com/uploadfile/2011/1030/20111030040816628.jpg";
tile.SquareContent = wideImageContent;
TileUpdateManager.CreateTileUpdaterForApplication().Update(tile.CreateNotification());
}</p> <p> private void ClearTile_Click(object sender, RoutedEventArgs e)
{
//清除Tile通知
TileUpdateManager.CreateTileUpdaterForApplication().Clear();
}
效果图片:

Badge:
复制代码
代码如下:private void BadgeNotice_Click(object sender, RoutedEventArgs e)
{
//Badge数字通知
BadgeNumericNotificationContent badge = new BadgeNumericNotificationContent(29);
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge.CreateNotification());
}</p> <p> private void BadgeImage_Click(object sender, RoutedEventArgs e)
{
//Badge状态图片通知
BadgeGlyphNotificationContent badge = new BadgeGlyphNotificationContent(GlyphValue.Paused);
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge.CreateNotification());
}</p> <p> private void BadgeClear_Click(object sender, RoutedEventArgs e)
{
//清楚Badge通知
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
}
图片效果见图片右下角:

Xaml:
复制代码
代码如下:<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Toast通知" HorizontalAlignment="Left" Name="ToastNotice"
Margin="250,172,0,0" VerticalAlignment="Top" Click="ToastNotice_Click"/>
<Button Content="Tile 通知" HorizontalAlignment="Left" Name="TileNotice"
Margin="394,172,0,0" VerticalAlignment="Top" Click="TileNotice_Click"/>
<Button Content="清除Tile通知" HorizontalAlignment="Left" Name="ClearTile"
Margin="559,172,0,0" VerticalAlignment="Top" Click="ClearTile_Click" />
<Button Content="Badge数字" HorizontalAlignment="Left" Name="BadgeNotice"
Margin="250,270,0,0" VerticalAlignment="Top" Click="BadgeNotice_Click"/>
<Button Content="Badge图片" HorizontalAlignment="Left" Name="BadgeImage"
Margin="394,270,0,0" VerticalAlignment="Top" Click="BadgeImage_Click" />
<Button Content="Badge清除" HorizontalAlignment="Left" x:Name="BadgeClear"
Margin="559,270,0,0" VerticalAlignment="Top" Click="BadgeClear_Click" />
</Grid>
最后如需源码请点击 Win8Notice_jb51net.rar 下载。
相关文章

Win8.1 KB5021294补丁月度更新汇总!(附完整更新日志)
微软已向用户发布了Win8.1月度更新汇总,补丁为KB5021294,下文为大家带来了详细的更新介绍,需要的朋友一起看看吧2022-12-15
微软警告:Win8.1系统即将停止支持,将很快弹窗提醒,建议购买 Win11/1
6月24日消息,据报道,微软正准备开展行动,通知Windows8.1用户关于该产品的停止支持日期,下面随小编一起来看看吧2022-06-24
这篇文章主要介绍了win8系统怎么加密文件?win8系统加密文件详细操作方法的相关资料,需要的朋友可以参考下本文详细内容介绍2022-06-13
win8系统如何设置开机密码?Win8系统设置开机密码操作教程
这篇文章主要介绍了win8系统如何设置开机密码?Win8系统设置开机密码操作教程的相关资料,需要的朋友可以参考下本文详细内容介绍2022-06-13
这篇文章主要介绍了Win8系统在后台运行打印机程序操作教程的相关资料,需要的朋友可以参考下本文详细内容介绍2022-06-13
Win8系统安全证书过期怎么办?Win8系统安全证书过期的解决方法
这篇文章主要介绍了Win8系统安全证书过期怎么办?Win8系统安全证书过期的解决方法的相关资料,需要的朋友可以参考下本文详细内容介绍2022-06-13
如何解决Win10浏览器打不开网页但能上网?最近很多用户向小编反应升级了win10系统之后在下载软件或者打开第三方网页的时候会出现病毒误报,该怎么办呢?跟随小编来看看吧2020-12-31
Win8临时文件夹如何修改路径?Win8临时文件夹文件过多会影响速度,我们可以通过修改文件路径很好的解决这一问题,下面让我们来看看如何修改2020-12-22
Win8系统如何设置鼠标左右键互换?最近很多小伙伴向小编咨询关于Win8系统设置鼠标左右键互换的问题,下面就跟随小编一起学习吧2020-12-11
Win8系统怎么关闭系统还原?最近很多win8系统的用户向小编咨询想要关闭系统还原,不知道如何操作,不妨我们一起来看看下文的教程吧2020-12-09












最新评论