I have a blazor function that is
public async Task DoSomething()
I have another class object like this:
public class SomeClass
{
public string Title { get; set; }
public string Icon { get; set; }
public EventCallback OnClick {get;set;}
}
This class object is consumed by blazor components. What I would like to do is to attach the DoSomething() event to the EventBackkBack OnClick in the class object. I tried this:
_collection.Add(new SomeClass{ Title = "some title", Icon = "icon", OnClick = DoSomething});
This does not work as the compiler is saying cannot convert to method group to non-delegate type EventCallBack ...
I can make it work if I change the property OnClick to "Action", but that requires the function call to be "async void". I cannot do that for other reasons.
Is there a way for me to attach this async Task function to OnClick? Thanks!