Live tiles do not collect image from isolated storage

In my WP7 application, I create an image for a live tile and save it in isolated storage. Then an updated live tile is available for my periodic task, and in this regard everything works fine for the periodic task.

I have a problem in my foreground WP7 application when I create a real-time image. I am also updating live tiles (since I know something has changed, so why wait for a periodic task). But when a real-time update occurs here, it seems that he cannot find the newly created file and therefore is a live tile without a bitmap.

In terms of the corresponding code

File creation

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 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); 

and actual conservation

 // 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, 173, 0, 100); // Close the stream, and by that saving the file to the ISF. stream.Close(); 

and code that actually extracts the image and updates the live fragment (and works in a periodic task, but not from the application itself

 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)), }); 

Just unsure if I am doing something fundamentally wrong here? I am considering storing the generated image in a database with its object. And here I have a manageable number of files. I do not generate hundreds of things.

I have a workaround which is to update the livetile from a WP7 application without using an image file.

+4
source share
2 answers

Hey, this code looks familiar ;-) Aside, nothing in the code you posted can actually identify the problem.

I assume that you are calling NotifyComplete() at an early stage in your periodic task. For this, I recommend that you use a parallel task library to solve this problem.

I actually wrote an article about this this morning: How: Live tile with a planned agent

The essential part is to let Task.ContinueWith make sure that NotifyComplete() first called after you have finished rendering the background image and saved it to the isolated storage.

+1
source

When creating in the main application, you do not need the isostore: prefix isostore: on the way. Try just creating a relative URI for the file.

0
source

All Articles