public System.Windows.Media.Imaging.WriteableBitmap renderTileImg(menu menuEntry, bool rendertitle = false)
        {
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                string i = (string)menuEntry.name;
                int    x = 0;
                int    y = 0;
                int    s = 0;
                int    z = 0;


                if (menuEntry.apps.Count < 5)
                {
                    s = 100;
                }
                else
                {
                    s = 67;
                }


                System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(200, 200);

                System.Windows.Media.Imaging.WriteableBitmap wb_back = new System.Windows.Media.Imaging.WriteableBitmap(200, 200);

                if (rendertitle)
                {
                    Rectangle rect = new Rectangle();
                    rect.Width  = 200;
                    rect.Height = 200;

                    Color clr = (Color)Application.Current.Resources["PhoneAccentColor"];
                    clr.A = 160;

                    rect.Fill = new SolidColorBrush(clr);

                    wb.Render(rect, null);
                    wb_back.Render(rect, null);
                }
                else
                {
                    Rectangle rect = new Rectangle();
                    rect.Width  = 200;
                    rect.Height = 200;

                    rect.Fill = new SolidColorBrush(Color.FromArgb(160, 0, 0, 0));

                    wb.Render(rect, null);
                    wb_back.Render(rect, null);
                }

                foreach (appentry app in menuEntry.apps)
                {
                    Image img = new Image();
                    img.Stretch = Stretch.Uniform;
                    img.Width   = s;
                    img.Height  = s;
                    BitmapImage bmp = new BitmapImage();
                    using (var file = store.OpenFile(app.guid + ".jpg", FileMode.Open, FileAccess.Read))
                    {
                        bmp.SetSource(file);
                    }
                    img.Source = bmp;

                    if (z < 9)
                    {
                        wb.Render(img, new TranslateTransform {
                            X = x, Y = y
                        });
                    }
                    else
                    {
                        wb_back.Render(img, new TranslateTransform {
                            X = x, Y = y
                        });
                    }
                    x += s;
                    if (x > 200 - (s - 5))
                    {
                        x  = 0;
                        y += s;
                    }
                    if (z == 8)
                    {
                        x = 0;
                        y = 0;
                    }
                    z++;
                }

                /*if (rendertitle)
                 * {
                 *  TextBlock title = new TextBlock();
                 *  title.FontSize = 21;
                 *  title.Text = i;
                 *  title.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
                 *
                 *  wb.Render(title, new TranslateTransform { X = 10, Y = 170 });
                 * }*/
                wb.Invalidate();

                System.Diagnostics.Debug.WriteLine(i);
                if (!rendertitle)
                {
                    var filename = "/Shared/ShellContent/tile_" + i + ".jpg";
                    using (var st = new IsolatedStorageFileStream(filename, FileMode.Create, FileAccess.Write, store))
                    {
                        WriteableBitmapExtensions.WritePNG(wb, st);
                    }
                    if (menuEntry.apps.Count > 9)
                    {
                        wb_back.Invalidate();
                        filename = "/Shared/ShellContent/tile_" + i + "_back.jpg";
                        using (var st = new IsolatedStorageFileStream(filename, FileMode.Create, FileAccess.Write, store))
                        {
                            WriteableBitmapExtensions.WritePNG(wb_back, st);
                        }
                    }
                }
                return(wb);
            }
        }