Errore di MVVM Toolkit MVVMTK0010

Impossibile impostare il nome CanExecute in [RelayCommand] in modo che corrisponda a più elementi nel tipo padre (deve fare riferimento a un singolo membro compatibile).

L'esempio seguente genera MVVMTK0010:

using CommunityToolkit.Mvvm.Input;

namespace MyApp;

public partial class SampleViewModel
{
    private bool Foo => true;

    private bool Foo() => true;

    // There are two members named "Foo", so the match is ambiguous
    [RelayCommand(CanExecute = nameof(Foo))]
    private void GreetUser()
    {
    }
}

Risorse aggiuntive

  • Altri esempi sono disponibili negli unit test.