Skip to content

[BUG] EventToCommandBehavior never invokes commands without CanExecute delegate #2856

@ahoke-cr

Description

@ahoke-cr

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

As observed in the source code, only when the command instance explicitly defines a CanExecute value will the behavior execute the command.

Expected Behavior

Commands that don't define CanExecute because they are always valid to execute should also be executed when the behavior proxies a raised event.

Steps To Reproduce

  1. Create a Command without a CanExecute delegate
  2. Add an EventToCommandBehavior to a view, binding to the command
  3. Raise the proxied event
public ICommand TestCommand { get; }

public TestViewModel(...)
{
    TestCommand = new Command(ExecuteMethod);
}

public void ExecuteMethod(object? parameter)
{
    Console.WriteLine("You won't see this");
}

Link to public reproduction project repository

no

Environment

- .NET MAUI CommunityToolkit: 12.2.0
- OS: Win11 x64 23H2 build 22631.5699
- .NET MAUI: 9.0.100

Anything else?

This worked fine in Xamarin.Essentials with XF 5.x so this is a frustrating regression as I upgrade my app on a tight time table.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions