Fix CameraView StopCameraPreviewCommand#3158
Open
zhitaop wants to merge 3 commits intoCommunityToolkit:mainfrom
Open
Fix CameraView StopCameraPreviewCommand#3158zhitaop wants to merge 3 commits intoCommunityToolkit:mainfrom
zhitaop wants to merge 3 commits intoCommunityToolkit:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a runtime InvalidCastException when binding CameraView.StopCameraPreviewCommand by reverting the command’s public/bindable type back to a non-generic command interface, matching the underlying StopCameraPreview() void API.
Changes:
- Change
StopCameraPreviewCommandPropertybindable type fromCommand<CancellationToken>toICommand. - Update the
StopCameraPreviewCommandproperty to returnICommandand remove CancellationToken-related XML docs that no longer apply.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+140
to
+142
| /// Gets the <see cref="ICommand"/> that stops the camera preview. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <see cref="StopCameraPreviewCommand"/> has a <see cref="Type"/> of Command<CancellationToken> which requires a <see cref="CancellationToken"/> as a CommandParameter. See <see cref="Command{CancellationToken}"/> and <see cref="System.Windows.Input.ICommand.Execute(object)"/> for more information on passing a <see cref="CancellationToken"/> into <see cref="Command{T}"/> as a CommandParameter | ||
| /// </remarks> | ||
| public Command<CancellationToken> StopCameraPreviewCommand => (Command<CancellationToken>)GetValue(StopCameraPreviewCommandProperty); | ||
| public ICommand StopCameraPreviewCommand => (ICommand)GetValue(StopCameraPreviewCommandProperty); |
2 tasks
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The
CameraView.StopCameraPreviewCommandwas changed from the typeICommandtoCommand<CancellationToken>in the commit 4ed306bHowever, the method
CameraView.StopCameraPreview()which theStopCameraPreviewCommandcalls internally has a return typevoidinstead of aTask. This means theStopCameraPreviewCommanddoes not need to use aCancelationToken.The fix for this issue is to revert the signature of
CameraView.StopCameraPreviewCommandtoICommandLinked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information