How to call camerax from xamarin forms

Aleksey 21 Reputation points
2021-08-09T19:50:27.187+00:00

hello friends
How to call camerax from xamarin forms
Is there a control for this to use in xaml

Developer technologies .NET Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,971 Reputation points
    2021-08-10T01:53:21.237+00:00

    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.