我遇到了一个奇怪的问题。我根据天气信息在BackgroundTask中生成实时平铺图像。有时我看到图像正在生成,但图块只显示其背景颜色而不是图像(例如,图块为绿色或红色,并且仅显示标题)。
当我移除实时图块并将其重新固定到开始屏幕时,图像会显示。或者,在Windows Phone 8上,当我更改大小(Small => Medium => Wide)时,实时图块显示图像就好了。它有时会出现在背景图像和BackBackground图像上。即使重新启动手机或打开应用程序似乎也有帮助(但不是100%)。
这似乎是Windows Phone操作系统中的一个小错误。可能是什么问题?
这是我的代码:
using (IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream imageStream = new IsolatedStorageFileStream("/Shared/ShellContent/Image.jpg", System.IO.FileMode.Create, ISF))
{
writeableTileFinal.SaveJpeg(imageStream, writeableTileFinal.PixelWidth, writeableTileFinal.PixelHeight, 0, 100);
}
}
ShellTile appTile = ShellTile.ActiveTiles.First();
if (appTile != null)
{
StandardTileData tileData = new StandardTileData()
{
Title = "Title",
BackContent = string.Empty,
BackTitle = string.Empty,
BackgroundImage = new Uri("isostore:/Shared/ShellContent/Image.jpg", UriKind.Absolute),
};
appTile.Update(tileData);
}
更新
我似乎已经通过在磁贴更新之前使用Thread.Sleep来修复它(之后没有发生)。:
Thread.Sleep(2000);
appTile.Update(tileData);
它有效,但有人知道可能出现什么问题吗?