private static void SaveTileBackgroundImage(TileViewModel model)
        {
            string xamlCode;

            using (var tileStream = Application.GetResourceStream(new Uri("/WP7LiveTileDemo;component/Controls/CustomTile.xaml", UriKind.Relative)).Stream)
            {
                using (var reader = new StreamReader(tileStream))
                {
                    xamlCode = reader.ReadToEnd();
                }
            }

            var control = (Control)XamlReader.Load(xamlCode);
            control.DataContext = model;

            var bitmap = new WriteableBitmap(173, 173);

            bitmap.Render(control, new TranslateTransform());

            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var stream = store.CreateFile(TileBackgroundPath))
                {
                    bitmap.Invalidate();
                    bitmap.SaveJpeg(stream, 173, 173, 0, 100);
                    stream.Close();
                }
            }
        }
        public static void UpdateTile(TileViewModel model)
        {
            if (!ShellTile.ActiveTiles.Any())
                return;

            SaveTileBackgroundImage(model);

            var tileData = new StandardTileData
            {
                BackgroundImage = TileBackgroundUri,
                Title = "WP7 Tile Demo",
                Count = null
            };

            foreach (var tile in ShellTile.ActiveTiles)
                tile.Update(tileData);
        }