user3742637
user3742637

Reputation: 1

Capture screen of the application on a Windows 10 Universal App

I need to capture the screen of my application to save it on the device. Is it possible with a Windows 10 Universal App?

Upvotes: 0

Views: 1542

Answers (1)

Rob Caplan - MSFT
Rob Caplan - MSFT

Reputation: 21899

If your app runs specifically on phones then it can use the ScreenCapture class from the Phone Contract. This isn't available on other device families.

On other devices you can capture the apps own window contents (but not others) by rendering it into an offscreen bitmap. For a Xaml app use the RenderTargetBitmap class to render the root of the page.

RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); 
await renderTargetBitmap.RenderAsync(pageRoot, width, height); 

Extract the image with GetPixelsAsync, encode to a bitmap (jpg, png, etc) with a BitmapEncoder then save or share the results.

Upvotes: 3

Related Questions