---
title: "Screenshots"
description: "Learn more about taking screenshots when an error occurs. Sentry pairs the screenshot with the original event, giving you additional insight into issues."
url: https://docs.sentry.io/platforms/dotnet/guides/maui/enriching-events/screenshots/
---

# Screenshots | Sentry for MAUI

Sentry makes it possible to automatically take a screenshot and include it as an [attachment](https://docs.sentry.io/platforms/dotnet/guides/maui/enriching-events/attachments.md) when a user experiences an error, an exception or a crash.

This feature is only available for SDKs with a user interface, such as the ones for mobile and desktop applications. In some environments like native iOS, taking a screenshot requires the UI thread and in the event of a crash, that might not be available. Another example where a screenshot might not be available is when the event happens before the screen starts to load. So inherently, this feature is a best effort solution.

## [Enabling Screenshots](https://docs.sentry.io/platforms/dotnet/guides/maui/enriching-events/screenshots.md#enabling-screenshots)

Because screenshots may contain [PII](https://docs.sentry.io/platforms/dotnet/guides/maui/data-management/sensitive-data.md), they are an opt-in feature. You can enable screenshots as shown below:

```csharp
var builder = MauiApp.CreateBuilder()
    .UseMauiApp<App>()
    .UseSentry(options =>
    {
        options.Dsn = "___PUBLIC_DSN___";
        options.SendDefaultPii = true;
        options.AttachScreenshot = true;

        // Set a Before Screenshot capture callback to execute some code before the screenshot is taken
        // This option is optional. if not set, the screenshots will be captured and sent.
        options.SetBeforeScreenshotCapture((@event, hint) =>
        {
              //
              // Your code here
              
              // Return true to capture or false to prevent the capture
              return true;
        });
    })
```

Capturing a screenshot is a synchronous operation supported on both iOS and Android. For iOS, a UI thread is required.

## [Viewing Screenshots](https://docs.sentry.io/platforms/dotnet/guides/maui/enriching-events/screenshots.md#viewing-screenshots)

If one is available, you'll see a thumbnail of the screenshot if you click on a specific issue from the [**Issues**](https://demo.sentry.io/issues/) page:

Once you've clicked on the event ID of a specific issue, you'll be able to see an overview of all the attachments as well as associated events in the "Attachments" tab.
