Reputation: 9863
I have tried both solutions below and they both have the same result. the tile is created but the image doesn't appear. I am able to set the title and other properties but when I use this solution it doesn't work. I have verified the image path and that it was in the build. Any Ideas?
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 });
}
And I also tried this solution
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);
}
Upvotes: 0
Views: 425
Reputation:
Are the image sizes correct? Did you set the images' build property to "Content"? Is it maybe necessary to set all properties in FlipTileData?
Upvotes: 1