Take a screenshot of the current user control or any GUI in Silverlight 3

I would like to ask if it is possible to programmatically save a screenshot of the current user control and save as a file in silverlight 3.

I found several ways to save the image as a canvas file for Canvas in silverlight 3, but what about user control or a child window?

Thank,

+5
source share
2 answers

Writable Bitmap lets you do this. See Examples and Examples.

+5
source

Not sure about silverlight 3, but in 4 he did like this:

public static byte[] CreatePngImage(this UIElement element)
{
    WriteableBitmap screenshot = new WriteableBitmap(element, new TranslateTransform());
    var image =  screenshot.ToImage();
    ImageTools.IO.Png.PngEncoder png = new ImageTools.IO.Png.PngEncoder();

    using (var mem = new System.IO.MemoryStream())
    {
        png.Encode(image, mem);
        var bytes = mem.GetBuffer();
        return bytes;
    }
}

ImageTools.IO.Png.dll

+2

All Articles