我正在嘗試使用生成的圖像更新應用程序圖塊。我沒有得到任何錯誤,但圖像現在只是黑色,而不是這種顏色:'Color.FromArgb(255,0,100,50)'。任何想法爲什麼?生成的圖像顏色錯誤的瓷磚
//This have to be the Image, just a colored squer for the beginning
var TestTile = new Grid()
{
Background = new SolidColorBrush(Color.FromArgb(255, 0, 100, 50)),
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch,
Height = 336,
Width = 336,
Margin = new Thickness(0, 12, 0, 0),
};
//generation the image and save it within isoStorage
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!store.DirectoryExists("shared/shellcontent"))
{
store.CreateDirectory("shared/shellcontent");
}
var bitmap = new WriteableBitmap(336, 336);
bitmap.Render(TestTile, new TranslateTransform());
var stream = store.CreateFile("/shared/shellcontent/test.jpg");
bitmap.Invalidate();
bitmap.SaveJpeg(stream, 366, 336, 0, 100);
stream.Close();
}
// Tile Update
ShellTile PinnedTile = ShellTile.ActiveTiles.First();
FlipTileData UpdatedTileData = new FlipTileData
{
BackgroundImage = new Uri("isostore:/shared/shellcontent/test.jpg", UriKind.RelativeOrAbsolute),
};
PinnedTile.Update(UpdatedTileData);
好,我會嘗試使用矩形的顏色設置爲背景 – user3168511