System pickers

Import images and documents with the native photo and file pickers.

ISystemPicker presents the system photo library and document browser. It returns in-memory PickedAsset values containing Data and Name.

The service is available through the dependency-injection setup described in application setup and DI, or through the protected SystemPicker property on any custom view:

public sealed class ProfileViewModel(ISystemPicker picker)
{
    public async Task ChooseAvatarAsync()
    {
        PickedAsset[]? assets = await picker.PickImagesAsync(limit: 1);
        if (assets is not [var avatar])
            return;

        Avatar = ImageSource.Data(avatar.Data);
    }
}

PickImagesAsync returns null when canceled or when nothing was selected. A limit of 1 is the default; larger values enable multiple selection.

Use PickFileAsync with extensions without leading dots:

PickedAsset? document = await picker.PickFileAsync("pdf", "md", "txt");
if (document is not null)
    await ImportAsync(document.Name, document.Data);

With no recognized extensions, the picker accepts any item. Extension filtering improves the system UI, but imported bytes still need format and size validation before parsing.

Picked assets are loaded fully into memory. For very large files or workflows that require security-scoped URLs and streaming, use a dedicated native picker integration rather than retaining the returned byte array.

The returned image bytes can be displayed through ImageSource.Data.