Skip to content

[BUG] CameraView StopCameraPreviewCommand is not working #3156

Closed

Description

@zhitaop

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

The CameraView.StopCameraPreviewCommand is not working correctly. When binding this command to a button, the app raises the following exception:

System.InvalidCastException: 'Unable to cast object of type 'Microsoft.Maui.Controls.Command' to type 'Microsoft.Maui.Controls.Command`1[System.Threading.CancellationToken]'.'

Image

Expected Behavior

The StopCameraPreviewCommand should work as expected.

Steps To Reproduce

  1. Run the CommunityToolkit.Maui.Sample app with the latest main branch on Windows (Note: might have to revert the commit 9aca2fc due to the issue [BUG] CommunityToolkit sample app crashes opening CameraView page on Windows #3155)
  2. Open the CameraView Page from the Views side menu
  3. Observe that the above exception is thrown
  4. Continue running the app. Observe that the "Stop Camera Preview" button does not work as expected.

Link to public reproduction project repository

https://github.com/CommunityToolkit/Maui/tree/main/samples

Environment

- .NET MAUI CommunityToolkit: v14.0.1
- .NET MAUI CommunityToolkit.Maui.Camera: v6.0.0
- OS: Windows 11 Enterprise
- .NET MAUI: 10.0.41

Anything else?

No response

Activity

  1. ne0rrmatrix commented on Mar 17, 2026

    @ne0rrmatrix
    Member

    @zhitaop please test #3157 and report back if that fixes your issue.

  2. zhitaop commented on Mar 17, 2026

    @zhitaop
    ContributorAuthor

    @ne0rrmatrix I've tested your branch locally. Opening the CameraView page does not throw the InvalidCastException anymore. However, the "Stop Camera Preview" button still does not work as expected.

    I've opened a PR #3158 which I believe should fix this issue properly. I've tested locally and the command is working as expected. Would you be able to take a look?

  3. locked and limited conversation to collaborators on Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions