Software solutions for a mobile world

As soon as I had submitted APPA Photo Navigator to the market place for certification, I thought of something that I should have added to it. One of the things that users love about Windows Phone apps are live tiles, and I realised I could use the photographs as cyclic live tiles, and pick 9 at random every time the application exited. Provided the user had pinned us to the home screen, they would get a rolling display of their photographs.

I soon realised that I wouldn't be able to use the pictures directly from the album, I would have to copy them to isolated storage. So, I wrote a routine to pick 9 photographs at random, and then copy them to isolated storage - not a problem. I even remembered to clear out isolated storage each time, so I didn't fill the users phone up with copies of photographs. Next step was to set the live tile to cycle round my 9 photographs, and use one as a base. I dug out some code I had already written in another app for setting up cyclic tiles.

At this point, I remembered that the CycleImages and SmallBackgroundImage took a Uri as their input, and not a BitmapImage as I had been thinking they did. Not a problem - I can easily get a list of the files in isolated storage, and pass them with a 'new Uri' statement. Compiled and deployed to my device, tested it, and I had a 'dead' live tile - just a plain coloured tile doing sweet FA. I used our GUI Iset tool (dogfooding at its best) to check that I did have 9 image files in isolated storage - and I did.

Realising that it must have something to do with the path, I googled, and found some code to get an absolute path to files in isolated storage. I bolted this in, and it did indeed return me an absolute path, including a couple of GUIDs and even "c:\\". This also compiled OK, but gave me a system exception, so back to Google. I also reached out on Twitter, and had a conversation with my friend Scott Lovegrove who suggested I should put the files in 'Shared/ShellContent'. I tried this, but still no dice, event though GUI Iset told me the files were in that folder within isolated storage.  

I then found an article which told me what I was trying to do was impossible, but Scott quite rightly pointed out the article I had found was talking about push notifications. At this point I decided to give up for a while, comment out the code, and sulk. Ideally I would have had some beer, as it was Saturday evening, but I am currently on a 'dryatholon' and not drinking.

The next morning, the always helpful Andy Wigley tweeted about this, letting me know the path should actually be 'isostore:/Shared/ShellContent'. This was followed by a 'doh' tweet from Scott who had forgotten he had done this on his code. So armed with this information, I uncommented the code from the previous evening, added 'isostore:' to my path, and tried again.

It worked!

    List<Uri> list = new List<Uri>();
    List<string> fileList = GetAllFiles();
    if (fileList.Count != 0)
          for (int i = 0; i < fileList.Count; i++)
                list.Add(new Uri("isostore:/Shared/ShellContent/" + fileList[i], UriKind.Absolute));
         CycleTileData tileData = new CycleTileData()
                  Title = "APPA Photos",
                  Count = null,
                  SmallBackgroundImage =
                            new Uri("isostore:/Shared/ShellContent/" + fileList[0], UriKind.RelativeOrAbsolute),
                  CycleImages = list
         var mainTile = ShellTile.ActiveTiles.FirstOrDefault();
         if (null != mainTile)

Thanks to Scott and Andy for their help in sorting this out - it is things like this what make the Windows Phone development community such a great place to be.

If you want to see how this looks in the finished version, please download APPA Photo Explorer - it is free - and if you like it, please give it some stars - Thanks.

Originally posted 12/Feb/2012


M: +44 (0)7860 907493




Twitter Feed