Advertisement
Beginner .NET MAUI, Device Features & Essentials

How do you pick or capture a photo in MAUI?

Short answer

Use MediaPicker.Default.PickPhotoAsync to choose from the gallery or CapturePhotoAsync to use the camera (camera requires permission and hardware). Both return a FileResult you can open as a stream to display or upload.

Save .NET MAUI mock interview
Advertisement
AModel answer
Use MediaPicker.Default.PickPhotoAsync to choose from the gallery or CapturePhotoAsync to use the camera (camera requires permission and hardware). Both return a FileResult you can open as a stream to display or upload.
var photo = await MediaPicker.Default.CapturePhotoAsync();
if (photo is not null)
{
    using var stream = await photo.OpenReadAsync();
    // save or display
}
Real-world example
A profile screen lets users take a new avatar photo or pick an existing one with a couple of lines.
Likely follow-ups
  • Does capture need permission? | What does PickPhotoAsync return?
Related topics