Class PhotoCaptureView
- Namespace
- VisioForge.Core.UI.MAUI
- Assembly
- VisioForge.Core.UI.MAUI.dll
A platform-native photo capture control for .NET MAUI that provides camera preview and photo capture capabilities.
public class PhotoCaptureView : View, INotifyPropertyChanged, IVisualTreeElement, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, IAnimatable, IViewController, IVisualElementController, IElementController, IGestureController, IGestureRecognizers, IPropertyMapperView, IHotReloadableView, IReplaceableView, IView, ITransform, IElementInheritance
Implements
Inherited Members
Remarks
This control is available only on iOS and Android platforms where it provides access to the device camera for photo capture operations. The control uses platform-specific camera implementations:
- iOS: AVFoundation-based camera capture
- Android: Camera2 API for modern devices
The actual camera functionality is implemented by the platform-specific VisioForge.Core.UI.MAUI.PhotoCaptureViewHandler which creates and manages the native camera views.
Key features:
- Real-time camera preview
- High-resolution photo capture
- Asynchronous photo saving
- Platform-optimized camera handling
Constructors
PhotoCaptureView()
Initializes a new instance of the VisioForge.Core.UI.MAUI.PhotoCaptureView class.
public PhotoCaptureView()Remarks
The camera preview and capture functionality is initialized by the platform-specific handler when the control is added to the visual tree. Camera permissions must be granted by the user before the camera can be accessed.
Methods
SavePhotoAsync(string)
Captures a photo from the camera and saves it to the specified file asynchronously.
public Task<bool> SavePhotoAsync(string filename)Parameters
filenamestring-
The full path where the captured photo should be saved. Must be a valid file path with write permissions.
Returns
- Task<bool>
-
A task that represents the asynchronous save operation. The task result contains: true if the photo was successfully captured and saved; false if the operation failed or the handler/core is not initialized.
Remarks
This method performs the following operations:
- Captures a photo using the device camera at the current settings
- Saves the captured image to the specified file path
- Returns the operation result asynchronously
The method requires that:
- The handler is initialized (control is in the visual tree)
- Camera permissions have been granted
- The specified file path is valid and writable
The image format and quality depend on the platform-specific camera implementation. On iOS, images are typically saved as JPEG. On Android, the format may vary based on device capabilities.
Exceptions
- UnauthorizedAccessException
-
Thrown when the application does not have permission to write to the specified file path.
- IOException
-
Thrown when an I/O error occurs during file write operations.