我正在使用以下代碼來獲取自定義用戶控件,將其創建爲位圖,然後將其保存到獨立存儲以實現此目的的WP8 Live Tile。使用動態圖像爲控件創建動態圖像的動態拼貼會拋出「NotSupportedException」
public static void UpdateTile()
{
var frontTile = new LiveTileRegular(); // Custom Control
frontTile.Measure(new Size(173, 173));
frontTile.Arrange(new Rect(0, 0, 173, 173));
var bmp = new WriteableBitmap(173, 173);
bmp.Render(frontTile, null);
bmp.Invalidate();
const string filename = "/LiveTiles/LiveTileRegular.jpg";
using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!isf.DirectoryExists("/LiveTiles"))
{
isf.CreateDirectory("/LiveTiles");
}
using (var stream = isf.OpenFile(filename, FileMode.OpenOrCreate))
{
bmp.SaveJpeg(stream, 173, 173, 0, 100);
}
Debug.WriteLine("Image Exists: " + (isf.FileExists(filename) ? "Yes" : "No")); // Displays "Yes"
}
ShellTile.ActiveTiles.First().Update(new FlipTileData
{
Title = "Title",
BackgroundImage = new Uri("isostore:" + filename, UriKind.Absolute),
}); // Throws a NotSupportedException
}
的NotSupportedException
被扔在ShellTile.ActiveTiles.First().Update()
方法具有非常非描述性消息。
有什麼我明顯做錯了嗎?
你是一個救星!正在摸索着我的頭! – soutarm 2013-07-13 03:57:10