Here is my code:
private readonly Dictionary<string, ComponentMetadata> components = new() { [nameof(ChoiceOfAnswerQuestion)] = new ComponentMetadata() { Type = typeof(ChoiceOfAnswerQuestion), Name = "Choix multiple", Parameters = { { nameof(ChoiceOfAnswerQuestion.OnValidSubmit), EventCallback.Factory.Create(this, HandleValidSubmit) }, { nameof(ChoiceOfAnswerQuestion.OnCancel), EventCallback.Factory.Create(this, CancelEdit) } } }, [nameof(AssociationQuestion)] = new ComponentMetadata() { Type = typeof(AssociationQuestion), Name = "Association", Parameters = { { nameof(AssociationQuestion.OnValidSubmit), EventCallback.Factory.Create(this, HandleValidSubmit) }, { nameof(AssociationQuestion.OnCancel), EventCallback.Factory.Create(this, CancelEdit) } } } };...
private async Task DeleteQuestion(int questionId){ ...}...
private async Task HandleValidSubmit(){ ...}The error occurs at "this". I don't know why but it doesn't take the "this". This is the complete message:
Keywork 'this' is not available in the current context
It should works, because my callback doesn't has argument and I should not pass any return type to the create because the functions are Task.
By the way, I've followed the EventCallBack section here:https://learn.microsoft.com/en-us/aspnet/core/blazor/components/dynamiccomponent?view=aspnetcore-8.0
Maybe you can help me?