When adding a newly created image to the secondary tile, it does not find it initially - why and how to fix it?
Full story
Hello, Iβm working on a Windows Phone application that creates secondary live fragments on the phoneβs main screen.
Since there is currently no easy way to generate a secondary live fragment with a given XAML, I do the following:
- Create a
UserControl
with this XAML and the data will bind it to my data. - Use
WriteableBitmap
to write after binding data to the image. - Use PNGWriter to write to isolated storage
- Create a live snippet using the generated
isostore:/
URL.
This view works, the problem is that the tile is created, but not displayed, only after the passage the tile suddenly appears correctly.
I use the following code to generate:
public static void GenerateMediumTile(DashboardViewModel source) { var image = new LiveTileMedium() {DataContext = source}; image.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); image.Arrange(new Rect(0,0,336,336)); var bitmap = new WriteableBitmap(336,336); bitmap.Render(image,new TranslateTransform()); bitmap.Invalidate(); using (var fileStore = IsolatedStorageFile.GetUserStoreForApplication()) { var file = fileStore.OpenFile("Shared/ShellContent/tile_" + source.Ticker + "_medium.png", FileMode.Create); bitmap.WritePNG(file.AsOutputStream().AsStreamForWrite()); } }
Then this code to create the tile:
var largeImageFile = isostoreSharedShellcontentTile + tileImage.Ticker + "_big.png"; var oFliptile = new FlipTileData { Title = "", BackTitle = "", BackContent = "", SmallBackgroundImage = new Uri("/Assets/Matrial/small_tile159x159.png", UriKind.RelativeOrAbsolute), BackgroundImage = new Uri(mediumImageFile, UriKind.Absolute), ... ShellTile.Create(new Uri(url, UriKind.Relative), oFliptile, true);
This is what a tile looks like when I create it, and then, as time passes, I enter another application.

