Hello,
Welcome to our Microsoft Q&A platform!
Camerax is Android native api which cannot be used in the shared project directly. You could define the function in the Android platform project and then call the function code in the shared project using DependencyService.
If you want to use a camera view in xaml, please try the Xamarin.Community.Toolkit.CameraView
control. The CameraView control enables the user to display a preview of the camera output, and it can take photos or record videos. For more details, you could refer to this doc.
<ContentPage ...
xmlns:xct="http://xamarin.com/schemas/2020/toolkit">
<StackLayout>
<xct:CameraView
x:Name="cameraView"
CaptureMode="Photo"
FlashMode="On"
HorizontalOptions="FillAndExpand"
MediaCaptured="CameraView_MediaCaptured"
OnAvailable="CameraView_OnAvailable"
VerticalOptions="FillAndExpand" />
</StackLayout>
</ContentPage>
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.