文件 – 实时图块不从孤立存储中拾取图像
在我的WP7应用程序中,我正在为实时图块生成图像并保存在隔离存储中.
然后它可用于我的周期性任务来更新实时图块,并且在这方面一切正常用于周期性任务. 当我创建实时图块图像时,我的问题是我的前景WP7应用程序中的点我也更新了实时图块(因为我知道某些内容已经改变,所以为什么要等待周期性任务).但是当在这里发生实时图块更新时,似乎找不到新创建的文件,因此呈现没有位图的实时图块. 就相关代码而言 创建文件 var source = new BitmapImage(new Uri("Images/Tiles/Class Timetable with T.png",UriKind.Relative)); source.CreateOptions = BitmapCreateOptions.None; source.ImageOpened += (sender,e) => // This is important. The image can't be rendered before it's loaded. { // Create our image as a control,so it can be rendered to the WriteableBitmap. var newImage = new Image(); newImage.Source = source; newImage.Width = 173; newImage.Height = 173; // Define the filename for our tile. Take note that a tile image *must* be saved in /Shared/ShellContent // or otherwise it won't display. var tileImage = string.Format("/Shared/ShellContent/{0}.jpg",Event.UniqueId); // Define the path to the isolatedstorage,so we can load our generated tile from there. var isoStoreTileImage = string.Format("isostore:{0}",tileImage); 和实际保存本身 // Create a stream to store our file in. var stream = store.CreateFile(tileImage); // Invalidate the bitmap to make it actually render. bitmap.Invalidate(); // Save it to our stream. bitmap.SaveJpeg(stream,173,100); // Close the stream,and by that saving the file to the ISF. stream.Close(); 以及实际检索图像并更新实时图块的代码(并且在周期性任务中工作但不在应用程序本身中工作 string imageString = "isostore:/Shared/ShellContent/" + nextEvent.UniqueId + ".jpg"; ShellTile defaultTile2 = ShellTile.ActiveTiles.First(); defaultTile2.Update(new StandardTileData { Title = nextTime,BackgroundImage = (new Uri(imageString,UriKind.Absolute)),}); 只是不确定我这里是否做了一些根本错误的事情?我正在考虑将生成的图像与其对象一起存储在数据库中.而且,我确实有一个可管理的文件数量.我没有产生数以百计的东西. 我有一个解决方法,即在不使用图像文件的情况下从WP7应用程序内更新livetile. 解决方法
嘿,代码看起来很熟悉;-)除此之外,您发布的代码中没有任何内容可以确定问题.
我的猜测是你在定期任务的早期调用NotifyComplete().为此,我建议您使用任务并行库来解决问题. 我今天早上写了一篇关于它的文章:How To: Live Tile with Scheduled Agent 关键部分是使用Task.ContinueWith确保在完成渲染背景图像后首先调用NotifyComplete(),并将其保存到隔离存储中. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows – 从IP地址解析主机名
- windows-runtime – Win 8.1 SearchBox – 绑定建议
- windows-phone-7 – 在WP7上使用MVVM时如何最好地将弹出窗口
- active-directory – 仅使用Microsoft提供的cmdlet测试Powe
- windows-10 – 使用VS2015和Windows 10的uap app左上角的两
- windows – 我们局域网内的视频会议有哪些软件
- 数百万UINT64 RGBZ图形像素的最快排序算法
- .net – 无法显示错误消息,因为找不到包含它的可选资源程序
- Windows(或Linux)中的不间断进程?
- windows-server-2008-r2 – Exchange 2010从多个域发送