适用于Windows Phone 8的自定义实时磁贴

时间:2014-04-10 10:38:45

标签: windows-phone-8 live-tile

我创建了一个应用程序,其中包含我自己的自定义实时图块 创建了三种大小的实时图块用户控件,但这里添加的只有一种尺寸(请参阅代码),我需要为其他两种尺寸(中小图块)添加相同尺寸。

这是来源 - Custom Live Tile

以下是Wide Tile的代码......

Dispatcher.BeginInvoke(() =>
   {
       // Render the new tile image
       RenderImageLibrary.WideTileControl wtc = 
            new RenderImageLibrary.WideTileControl(tempMain, descr, loc);
       wtc.SaveJpegComplete += async (s, args) =>
       {
           try
           {
              if (args.Success)
              {
                 // Set the tile image URI - "isostore:/" is important! Note that the control already
                 // puts the image into /Shared/ShellContent which is where tile images in the local folder must be
                 Uri tileImageUri = new Uri("isostore:/" + args.ImageFileName, UriKind.RelativeOrAbsolute);
                 Debug.WriteLine(tileImageUri.ToString());

                 // Set the tile image
                 FlipTileData ftd = new FlipTileData();
                 ftd.WideBackgroundImage = tileImageUri;

                 ShellTile.ActiveTiles.First().Update(ftd);
              }
              else
              {
                 Debug.WriteLine(args.Exception.ToString());
              }
           }
           catch (Exception ex)
           {
              Debug.WriteLine(ex.ToString());
           }
       };
       wtc.BeginSaveJpeg();
   });

1 个答案:

答案 0 :(得分:2)

您可以使用

ftd.BackgroundImage = tileImageUri; ftd.SmallBackgroundImage = tileImageUri;

有关FlipTileData的更多信息,请参阅http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.shell.fliptiledata