Unable to pass one parameter to lambda function in MVVM Light Toolkit RelayCommand

I don’t know if there is a difference between the implementation of Josh Smith and Laurent Bugnion RelayCommand or not, but wherever I looked, it looks like the Execute RelayCommand part can take 0 or 1 parameters. I was only able to make it work with 0. When I try something like:

public class Test
{
    public RelayCommand MyCommand { get; set; }

    public Test()
    {
        MyCommand = new RelayCommand((param) => SomeFunc(param));
    }

    private void SomeFunc( object param)
    {
    }
}

I get an error: Delegate 'System.Action' does not take '1' arguments. Just to make sure I’m not crazy, I went over to the definition of RelayCommand to make sure I didn’t have some kind of fraudulent implementation in my solution somewhere, but of course it was just Action, not Action <> .

What am I missing here?

+3
source share
1 answer

RelayCommand ( MVVM Light) . RelayCommand<Object> ( ) RelayCommand<YourCustomType>, SomeFunc .

+7

Source: https://habr.com/ru/post/1748784/


All Articles