O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating Dynamic Images with RenderTargetBitmap

RenderTargetBitmap enables you to take a screenshot of any UIElement, even your entire Page! To use it, instantiate one and then call its RenderAsync method with the root UIElement to capture:

RenderTargetBitmap rtb = new RenderTargetBitmap();await rtb.RenderAsync(element);

Because RenderTargetBitmap is an ImageSource, you can use it as the source of any Image element. To extract the image data to use for other purposes, you call GetPixelsAsync to get back an IBuffer:

IBuffer buffer = await rtb.GetPixelsAsync();

From this point, you can interact with the IBuffer the same way you would with one obtained from WriteableBitmap, such as calling ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required