Language

ViewExtensions.CaptureAsync(IView) Method

Definition

Captures a screenshot of the specified view.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<Microsoft::Maui::Media::IScreenshotResult ^> ^ CaptureAsync(Microsoft::Maui::IView ^ view);
public static System.Threading.Tasks.Task<Microsoft.Maui.Media.IScreenshotResult?> CaptureAsync(this Microsoft.Maui.IView view);
static member CaptureAsync : Microsoft.Maui.IView -> System.Threading.Tasks.Task<Microsoft.Maui.Media.IScreenshotResult>
<Extension()>
Public Function CaptureAsync (view As IView) As Task(Of IScreenshotResult)

Parameters

view
IView

Returns

Remarks

On non-built-in platform TFMs (e.g. net10.0-macos AppKit backends, net10.0 Linux/GTK backends) where MAUI does not ship a screenshot implementation, capture is routed through the registered screenshot service. Third-party platform backends opt in by registering an IScreenshot implementation that also implements IViewScreenshot in the app's IServiceProvider:

builder.Services.AddSingleton<IScreenshot, AppKitScreenshotImplementation>();

The dispatch resolves that service from the handler's MauiContext and forwards the view's container view (or, failing that, its platform view) to CaptureViewAsync(Object). When no capable service is registered (or the PlatformView is null), the returned task resolves to null.

Applies to