0
我已經嘗試了下面的兩種解決方案,他們都有相同的結果。該瓷磚已創建,但圖像未顯示。我可以設置標題和其他屬性,但是當我使用此解決方案時,它不起作用。我已經驗證了圖像路徑並且它在構建中。有任何想法嗎?Windows Phone 7.8 WideTile圖像不起作用
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);
}
我認爲它可能是圖像尺寸,但我不知道所需的尺寸。我確實將構建屬性設置爲無內容。我也將其設置爲始終複製。我會嘗試設置所有的屬性,但標題屬性的作品沒有全部設置,所以我對這種方法沒有太多的信心哈哈。 –
此處的平鋪尺寸=> http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/hh202948(v=vs.105).aspx#BKMK_Tilesizesandresolutions – xmashallax
由於某些原因,Build屬性未設置爲儘管它說的是內容。一旦我明白了這一點,我只是從項目中刪除圖像,重新添加它,然後將其構建屬性設置爲內容和始終複製。奇蹟般有效。謝謝 –