WindowExtensions.CaptureAsync(IWindow) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Captures a screenshot of the specified window.
public:
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<Microsoft::Maui::Media::IScreenshotResult ^> ^ CaptureAsync(Microsoft::Maui::IWindow ^ window);
public static System.Threading.Tasks.Task<Microsoft.Maui.Media.IScreenshotResult?> CaptureAsync(this Microsoft.Maui.IWindow window);
static member CaptureAsync : Microsoft.Maui.IWindow -> System.Threading.Tasks.Task<Microsoft.Maui.Media.IScreenshotResult>
<Extension()>
Public Function CaptureAsync (window As IWindow) As Task(Of IScreenshotResult)
Parameters
- window
- IWindow
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 window's platform view to CaptureViewAsync(Object). When no capable service is registered (or the PlatformView is null), the returned task resolves to null.