CameraView torch support - #3211
Merged
TheCodeTraveler merged 6 commits intoMay 8, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements handler/property-mapper support for CameraView.IsTorchOn, enabling torch control through the Toolkit CameraView across platforms, and updates the sample UI to demonstrate the feature.
Changes:
- Added
IsTorchOnproperty mapping inCameraViewHandlerand routed it to a newCameraManager.UpdateIsTorchOn(...)API. - Implemented
UpdateIsTorchOn(...)for Android, iOS/macOS, and Windows (andnetfallback as not supported). - Updated the CameraView sample page + view model to toggle torch state via a checkbox.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs | Adds property mapper entry and mapping method for IsTorchOn. |
| src/CommunityToolkit.Maui.Camera/CameraManager.shared.cs | Introduces UpdateIsTorchOn(bool) as a new cross-platform partial method. |
| src/CommunityToolkit.Maui.Camera/CameraManager.android.cs | Implements torch toggling via CameraX EnableTorch. |
| src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs | Implements torch toggling via AVCaptureDevice.TorchMode. |
| src/CommunityToolkit.Maui.Camera/CameraManager.windows.cs | Implements torch toggling via TorchControl.Enabled. |
| src/CommunityToolkit.Maui.Camera/CameraManager.net.cs | Adds not-supported stub for UpdateIsTorchOn. |
| samples/CommunityToolkit.Maui.Sample/ViewModels/Views/CameraView/CameraViewViewModel.cs | Adds IsTorchOn observable property for the sample. |
| samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml | Wires CameraView.IsTorchOn + checkbox to the sample view model. |
Contributor
Author
|
My tests on an iPad mini 6. Gen was successful, the torch checkbox in the sample correctly toggles the torch light. |
TheCodeTraveler
approved these changes
May 8, 2026
TheCodeTraveler
left a comment
Collaborator
There was a problem hiding this comment.
Fantastic work @MFinkBK!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
This implements the property mapper for the
CameraViewpropertyIsTorchOn. I based the property mapper on the code in theZXing.Net.MAUIrepository.Tests were omitted, since this is not possible to test automatically. It has a sample, though. I didn't create a Documentation PR, since the property is already documented:
https://github.com/MicrosoftDocs/CommunityToolkit/blob/07e8463e67e4e24ed93d67490197cf4548537b71/docs/maui/views/camera-view.md?plain=1#L749
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
I tested this with an Android device. I will test it also on an iOS device, as soon as I figure out my deployment problems. Unfortunately I don't have a Windows device with integrated flash, so I couldn't test it on that platform.