Blazor - cannot convert from 'method group' to 'EventCallback'

For some reason Visual Studio kept a previous signature I had used. Cleaning, restarting, emptying bin/obj folders etc did not work. I had to rename the method, which worked for me.


You were close:

<ChildComponent Item="someModel" T="SomeModel" DeleteCallback="OnDeleteSomeModel" />

@code {
    SomeModel someModel = new SomeModel();

    void OnDeleteSomeModel(SomeModel someModel)
    {
        ...
    }
}

The EventCallback uses a generic type and blazor cannot infer it if you don't pass the type to the component.

This means that if you have a EventCallback<T> you need to pass the value of T to the component e.g. T="SomeType".


In my case I declared a nullable EventCallback? - you can't do that.


I've experienced that the syntax was spot on and still getting this error.

Restarting Visual Studio 2019 solved the problem for me. Cleaning and rebuilding was not enough.