[WindowsPhone] 隨貼即用 - 建立翻轉Tile

2013-10-22

簡述 : 建立可以翻轉的Tile

難度 : ★★★

範例敘述:  一顆按鈕,按下後建立可以翻轉的Tile

程式碼:


private void btnCreateFlipTile_Click(object sender, RoutedEventArgs e)
 {
     //將所有已經建立過的Tile都撈出來看看,如果已經建立過了 他必定連結位置包含 "參數A"
     ShellTile tUsedTile = ShellTile.ActiveTiles.FirstOrDefault(
                     tX => tX.NavigationUri.ToString().Contains("參數A"));
 
     //如果現在沒有在檯面上,就建立
     if (tUsedTile == null)
     {
         FlipTileData TileData = new FlipTileData()
             {
                 Title = "前標題",
                 BackTitle = "後面標題",
                 BackContent = "中型後面內容",
                 WideBackContent = "大寬型後面文字內容",
                 //數字
                 Count = 94,
                 //小圖
                 SmallBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileSmall.png", UriKind.Relative),
 
                 //中型背景圖
                 BackgroundImage = new Uri("Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative),
                 //中型背景圖(後方)
                 BackBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative),
 
                 //大型背景圖
                 WideBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative),
 
                 //大型背景圖後方
                 WideBackBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative)
             };
 
         ShellTile.Create(new Uri("/MainPage.xaml?key=參數A", UriKind.Relative), TileData, true);
     }
     else
     {
         MessageBox.Show("已經建立過囉");
     }
 }

範例結果:

2013-10-22_174702

2013-10-22_174707

2013-10-22_174719

2013-10-22_174725

注意事項:

1.記得先引用

using using Microsoft.Phone.Shell;

參考連結:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh239052(v=vs.105).aspx
http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/jj206971(v=vs.105).aspx
Windows Phone 8 – Tiles大進化

下載源碼:


當麻許的超技八 2014 | Donma Hsu Design.