Answer the question
In order to leave comments, you need to log in
How to subscribe to an event?
Hitch with syntax in +=
public interface IContentState {
public EventCallback<IContentState> OnStateChanged { get; set; }
}
public class Parent : IContentState {
public EventCallback<IContentState> OnStateChanged { get; set; }
private async Task StateChangedInvoke() {
await OnStateChanged.InvokeAsync(this);
}
}
public class Child() {
public void RegisterContent(IContentState contentState) {
ContentState.OnStateChanged += OnContentStateChanged;
}
protected void OnContentStateChanged(IContentState contentState) {
// do
}
}
Answer the question
In order to leave comments, you need to log in
You do not have an event in IContentState, but just a delegate.
Try to write
public event EventCallback<IContentState> StateChanged;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question