Simple Blazor WASM Application. Using Mediator to trigger different validations on a registration form (Multiple Pages). Mediator is publishing the validation notification and the current or active form is then handling that notification and validating the form.
On Render the model and element reference are correctly initialized with a value. But once in the handler both the model and form (element reference) are null???
@implements INotificationHandler<ValidateRegistrationNotification>
@inject IRegistrationService RegService
@inject IMediator Mediator
<MudForm Model="@model" @ref="form" Validation="@(validator.ValidateValue)">
</MudForm>
@code {
private MudForm? form { get; set; }
private FormPersonalDetailModel? model { get; set; }
private FormPersonalDetailValidator validator = new();
protected override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
model = RegService.Registration.FormPersonalDetail;
StateHasChanged();
}
return base.OnAfterRenderAsync(firstRender);
}
public async Task Handle(ValidateRegistrationNotification validate, CancellationToken cancellationToken)
{
if (validate.StageType == typeof(FormPersonalDetailModel))
{
await form!.Validate();
if (form.IsValid)
{
RegService.GoToNextStage();
}
}
}
On After Render Async On After Render Variable Values

Handle
Mediator Handle Variable Values
