Xamarin Community Toolkit CameraView
The CameraView control enables the user to display a preview of the camera output. In addition, it can take photos or record videos. The CameraView also offers the options you would expect to support taking photos and recording videos such as turning the flash on or off, saving the captured media to a file, and offering different hooks for events.
Syntax
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:Class="MyLittleApp.MainPage">
<StackLayout>
<xct:CameraView
x:Name="cameraView"
CaptureMode="Video"
FlashMode="On"
HorizontalOptions="FillAndExpand"
MediaCaptured="CameraView_MediaCaptured"
OnAvailable="CameraView_OnAvailable"
VerticalOptions="FillAndExpand" />
</StackLayout>
</ContentPage>
Properties
Property | Type | Description |
---|---|---|
CameraOptions | CameraOptions | Gets or sets which camera device should be used for the CameraView. |
CaptureMode | CameraCaptureMode | Gets or sets the capture mode for the CameraView. Either default, video or photo. |
FlashMode | CameraFlashMode | Gets or sets the flash mode of the CameraView. |
IsAvailable | bool | Gets or sets if the camera device is currently available for use. |
IsBusy | bool | Gets or sets if the camera is currently busy capturing media. |
MaxZoom | double | Gets or sets the maximum zoom level of the CameraView. |
ShutterCommand | ICommand |
Gets or sets a Command that is invoked when the shutter is triggered. |
VideoStabilization | bool | Gets or sets the video stabilization on the camera of the CameraView. |
Zoom | double | Gets or sets the current zoom level of the CameraView. |
Events
Event | Type | Description |
---|---|---|
MediaCaptured | EventHandler<MediaCapturedEventArgs> | Event that is triggered whenever media is captured successfully. |
MediaCaptureFailed | EventHandler<string> | Event that is triggered whenever media capture failed. |
OnAvailable | EventHandler<bool> | Event that is triggered whenever the selected camera device availability changes. |
Sample
You can see this in action in the Xamarin Community Toolkit Sample App.