How to customize a window to take a photo

Issue

For an android phone.

In .net MAUI, I want to customize a window with a “Take Photo” button, once this button is clicked I want to take a photo.

I know in Xamarin, I can install package Xam.Plugin.Media and then call Plugin.Media.CrossMedia.Current.TakePhotoAsync method to take a photo but I don’t know how to do it in MAUI. I don’t know if I need to install any packages for MAUI.

I know in MAUI, I can use Microsoft.Maui.Essentials and call MediaPicker.CapturePhotoAsync() to take a photo, but this method calls the default Camera app of the mobile device.

Solution

You can either go and implement your own wrapper for a camera control which, especially for Android, is not really a fun task.

So the other option is to look at the Xamarin Community Toolkit which has a CameraView. At the time of writing we don’t yet have our .NET MAUI package ready, but we’re working hard on it and should have the first previews this month.

Answered By – Gerald Versluis

Leave a Comment