Screenshot

This article describes how you can use the .NET Multi-platform App UI (.NET MAUI) IScreenshot interface. This interfaces lets you take a capture of the current displayed screen of the app.

The default implementation of the IScreenshot interface is available through the Screenshot.Default property. Both the IScreenshot interface and Screenshot class are contained in the Microsoft.Maui.Media namespace.

Capture a screenshot

To capture a screenshot of the current app, use the CaptureAsync method. This method returns a IScreenshotResult, which contains information about the capture, such as the width and height of the screenshot. IScreenshotResult also includes a Stream property that is used to convert the screenshot into an image object for use by your app. The following example demonstrates a method that captures a screenshot and returns it as an ImageSource.

public async Task<ImageSource> TakeScreenshotAsync()
{
    if (Screenshot.Default.IsCaptureSupported)
    {
        IScreenshotResult screen = await Screenshot.Default.CaptureAsync();

        Stream stream = await screen.OpenReadAsync();

        return ImageSource.FromStream(() => stream);
    }

    return null;
}

Limitations

Not all views support being captured at a screen level, such as an OpenGL view.