我尝试将UserControl渲染为图像,然后将其分配给辅助磁贴并固定它。生成的URI是
isostore:/Shared/ShellContent/CustomTile.jpg
但是,我收到以下错误: ExceptionObject = {System.ArgumentException:值不在预期范围内。 在 Windows.UI.StartScreen.SecondaryTileVisualElements.put_Square150x150Logo(Uri值) 在NestWP.ActionTiles.d__1.MoveNext()
我有这段代码
var customTile = new ActionTileControl();
customTile.Measure(new Size(150, 150));
customTile.Arrange(new Rect(0, 0, 150, 150));
var bmp = new WriteableBitmap(150, 150);
bmp.Render(customTile, null);
bmp.Invalidate();
const string filename = "/Shared/ShellContent/CustomTile.jpg";
using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!isf.DirectoryExists("/CustomLiveTiles"))
{
isf.CreateDirectory("/CustomLiveTiles");
}
using (var stream = isf.OpenFile(filename, System.IO.FileMode.OpenOrCreate))
{
bmp.SaveJpeg(stream, 336, 366, 0, 100);
stream.Close();
}
bool ex = isf.FileExists(filename);
ex = ex;
}
string urilink = "isostore:" + filename;
SecondaryTile secondaryTile = new SecondaryTile()
{
TileId = "tileid",
DisplayName = "title",
Arguments = "args"
};
//Error on the line below
secondaryTile.VisualElements.Square150x150Logo = new Uri(urilink, UriKind.Absolute);
secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = false;
bool isPinned = await secondaryTile.RequestCreateAsync();
我检查了FileExists,bool返回true。
如何将图像设置为辅助图块?
答案 0 :(得分:1)