Take the 2-minute tour ×

I'd like to make a application, like this one. The application enables to make a tile with text.

I found that I couldn't write text in tile easily, because StandardTileData class dosen't have such a function to write text in tile. StandardTileData class just enables to set Title, BackgroundImage, Count, etc. The sample is like this.

StandardTileData secondaryTile = new StandardTileData
    BackgroundImage = new Uri("/TileColors..png", UriKind.Relative),
    Title = "title",
    Count = null,
ShellTile.Create(new Uri("/MainPage.xaml?id=1", UriKind.Relative), secondaryTile);

So, I think we may need to make bitmap image included text. I don't have other good ideas. Does anyone know how to make bitmap image from stackpanel ?

My code is like this,

<StackPanel Height="173" Width="173" x:Name="TilePanel" Background="Wheat" >
    <TextBlock x:Name="tileText" Text="I'd like to add the text to a tile." Style="{StaticResource PhoneTextNormalStyle}" HorizontalAlignment="Left"  FontSize="20"/>
share|improve this question

1 Answer 1

maybe that function will help you out:

    public static void SaveToIsolatedStorage(FrameworkElement element, string file, bool scaled=true)
            var bmp = new WriteableBitmap(element, null);
            IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();

            double width = Math.Round(element.ActualWidth * ((double)Application.Current.Host.Content.ScaleFactor / 100f), MidpointRounding.AwayFromZero);
            double height = Math.Round(element.ActualHeight * ((double)Application.Current.Host.Content.ScaleFactor / 100f), MidpointRounding.AwayFromZero);

            if (!scaled)
                width = element.ActualWidth;
                height = element.ActualHeight;

            using (var stream = iso.CreateFile(file))
                bmp.SaveJpeg(stream, (int)width, (int)height, 0, 100);


    SaveToIsolatedStorage(uiElement, "uiElement_as_screenshot.jpg");

Edith: it seems i am late on this one but it could help anyone else ;)

share|improve this answer

Your Answer


