Blazor – cannot convert from ‘method group’ to ‘EventCallback’

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".

Leave a Comment

tech