0

我已经尝试了以下两种解决方案,它们都有相同的结果。磁贴已创建,但图像未出现。我可以设置标题和其他属性,但是当我使用这个解决方案时它不起作用。我已经验证了图像路径并且它在构建中。有任何想法吗?

public static void UpdateFlipTile(
            Uri wideBackgroundImage, 
            Uri wideBackBackgroundImage)
{
   if (IsTargetedVersion)
   {
  // Get the new FlipTileData type.
  Type flipTileDataType = Type.GetType("Microsoft.Phone.Shell.FlipTileData, Microsoft.Phone");

  // Get the ShellTile type so we can call the new version of "Update" that takes the new Tile templates.
  Type shellTileType = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");

  // Loop through any existing Tiles that are pinned to Start.
  foreach (var tileToUpdate in ShellTile.ActiveTiles)
  {
     // Look for a match based on the Tile's NavigationUri (tileId).

        // Get the constructor for the new FlipTileData class and assign it to our variable to hold the Tile properties.
        var UpdateTileData = flipTileDataType.GetConstructor(new Type[] { }).Invoke(null);

        // Set the properties. 
        SetProperty(UpdateTileData, "WideBackgroundImage", wideBackgroundImage);
        SetProperty(UpdateTileData, "WideBackBackgroundImage", wideBackBackgroundImage);


        // Invoke the new version of ShellTile.Update.
        shellTileType.GetMethod("Update").Invoke(tileToUpdate, new Object[] { UpdateTileData });

            break;

      }
   }

}

private static void SetProperty(object instance, string name, object value)
{
   var setMethod = instance.GetType().GetProperty(name).GetSetMethod();
   setMethod.Invoke(instance, new object[] { value });
}

我也尝试了这个解决方案

    if (Environment.OSVersion.Version >= new Version(7, 10, 8858))
{
    var tile = ShellTile.ActiveTiles.First();
    var flipTileData = new FlipTileData
            {
                BackgroundImage = new Uri("/Icons/MediumLogo.png", UriKind.RelativeOrAbsolute),
                WideBackgroundImage = new Uri("/Icons/WideLogo.png", UriKind.RelativeOrAbsolute),
            };
    tile.Update(flipTileData);
}
4

1 回答 1

1

图像尺寸是否正确?您是否将图像的构建属性设置为“内容”?是否有必要在 FlipTileData 中设置所有属性?

于 2013-04-17T22:52:49.127 回答