Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerating a secondary tile with image not showing image immediately
    primarykey
    data
    text
    <p>When adding a newly generated image to a secondary tile, it doesn't find it initially - why and how do I fix it?</p> <h3>The full story</h3> <p>Hello, I'm working on a Windows Phone application that creates secondary live tiles on the phone's home screen.</p> <p>Since there is currently no easy way to generate a secondary live tile with given XAML I do the following:</p> <ul> <li>Create a <code>UserControl</code> with given XAML and data bind it to my data</li> <li>Use <code>WriteableBitmap</code> to write it after data binding to an image.</li> <li>Use PNGWriter to write it to isolated storage</li> <li>Create the live tile with the generated <code>isostore:/</code> url.</li> </ul> <p>This <em>kinda</em> works, the problem is when the tile is created it's not showing, only after time passes the tile suddenly appears correctly.</p> <p>I use the following code for generation:</p> <pre><code>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()); } } </code></pre> <p>Then this code for creating the tile:</p> <pre><code>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); </code></pre> <p>Here is what the tile looks like when I'm creating it, and then after time passes and I enter another app.</p> <p><img src="https://i.stack.imgur.com/d9lrPm.jpg" alt="enter image description here"> <img src="https://i.stack.imgur.com/AAeHRm.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload