In Blazor, the EventCallback struct is a bit different from standard events, being single-cast instead of multi-cast, etc. For that reason, I don't think this is a duplicate.
I am trying to create a set of components that all have the same [parameter] EventCallback, and it seems reasonable to use an interface to enforce that... So far this doesn't seem to be possible.
Things I've tried:
Treating this like EventHandler
public interface IResolver
{
event EventCallback Done;
}
This raises the error: Event must be a delegate type.
...And other variations on trying to make this work like an EventHandler.
Trying to use IEventCallback
EventCallback implements IEventCallback, so this seemd promising. However, it is an internal interface, and is not available to me.
Using a base class instead
This seems like it might work, but I am curious why I can't do this with an interface.
Also found:
- Event must be of delegate type?
- Various articles about implementing event-like constructs using interfaces, or help with EventHandler, which is not the same thing.
None of that seems to be related to this problem.
EventCallback
as an ordinary property on the interface? - Kirk Wollpublic EventCallback MyCallBack { get; set; }
in your interface? - MrC aka Shaun Curtis[Parameter]
in the implementation class. - MrC aka Shaun Curtis