Welcome

首页 / 软件开发 / .NET编程技术 / Windows 8 Store Apps学习(36) 通知: Tile 详解

Windows 8 Store Apps学习(36) 通知: Tile 详解2013-12-06 cnblogs webabcd介绍

重新想象 Windows 8 Store Apps 之 通知

Tile - 基本应用参见 http://www.cnblogs.com/webabcd/archive/2013/06/17/3139740.html

Tile - 全部 Tile 模板

Tile - 在一个 Tile 上循环显示多个 TileNotification

Tile - 一个 app 多个 Tile

Tile - 按计划更新 Tile 通知, 轮询服务端以更新 Tile 通知

示例

1、显示 Tile 的全部 46 种模板

Notification/Tile/AllTemplates.xaml

<Pagex:Class="XamlDemo.Notification.Tile.AllTemplates"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="using:XamlDemo.Notification.Tile"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d"><Grid Background="Transparent"><Grid.Resources><Style x:Key="ItemTitleStyle" TargetType="TextBlock"><Setter Property="FontSize" Value="14.667"/></Style><ItemsPanelTemplate x:Key="StoreFrontGridItemsPanelTemplate"><WrapGrid MaximumRowsOrColumns="3" VerticalChildrenAlignment="Top" HorizontalChildrenAlignment="Left"/></ItemsPanelTemplate><Style x:Key="StoreFrontTileStyle"TargetType="GridViewItem"><Setter Property="FontFamily" Value="Segoe UI" /><Setter Property="Height" Value="300" /><Setter Property="Width" Value="260" /><Setter Property="Padding" Value="0" /><Setter Property="Margin" Value="0" /><Setter Property="HorizontalContentAlignment" Value="Left" /><Setter Property="VerticalContentAlignment" Value="Top" /><Setter Property="BorderThickness" Value="0"/><Setter Property="TabNavigation" Value="Local" /></Style><DataTemplate x:Key="StoreFrontTileTemplate"><Grid HorizontalAlignment="Left" Background="Transparent"><StackPanel Orientation="Vertical"><TextBlock TextWrapping="Wrap" VerticalAlignment="Center" Text="{Binding FileName}" HorizontalAlignment="Left" /><Image Source="{Binding Path}" Stretch="None" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,10,0,0"/></StackPanel></Grid></DataTemplate></Grid.Resources><!--显示 46 种不同的 Tile 模板--><GridView x:Name="gridView" Margin="120 0 0 0"ItemTemplate="{StaticResource StoreFrontTileTemplate}"ItemContainerStyle="{StaticResource StoreFrontTileStyle}"ItemsPanel="{StaticResource StoreFrontGridItemsPanelTemplate}"BorderBrush="LightGray" VerticalAlignment="Top"ScrollViewer.VerticalScrollBarVisibility="Auto"ScrollViewer.HorizontalScrollBarVisibility="Auto"SelectionMode="None" /></Grid></Page>
Notification/Tile/AllTemplates.xaml.cs

/* * 显示 Tile 的全部 46 种模板 */using System;using System.Linq;using Windows.ApplicationModel;using Windows.UI.Xaml.Controls;using Windows.UI.Xaml.Navigation;namespace XamlDemo.Notification.Tile{public sealed partial class AllTemplates : Page{public AllTemplates(){this.InitializeComponent();}protected async override void OnNavigatedTo(NavigationEventArgs e){// XamlDemo/Notification/Tile/TemplateDemo 文件夹内 46 张图片分别用于演示 Tile 的 46 种模板var folder = await Package.Current.InstalledLocation.GetFolderAsync(@"NotificationTileTemplateDemo");var files = await folder.GetFilesAsync();var dataSource = from p in files select new { FileName = p.DisplayName, Path = "ms-appx:///Notification/Tile/TemplateDemo/" + p.Name };gridView.ItemsSource = dataSource;}}}