Windows Phone 7.8宽幅图像不工作
本文关键字:图像 工作 Phone Windows | 更新日期: 2023-09-27 18:09:47
我已经尝试了下面两种解决方案,它们都有相同的结果。创建了磁贴,但没有显示图像。我能够设置标题和其他属性,但当我使用这个解决方案时,它不起作用。我已经验证了映像路径,并且它在构建中。什么好主意吗?
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);
}
图片大小是否正确?您是否将图像的构建属性设置为"内容"?是否有必要在FlipTileData中设置所有属性?