I have a long overdue UI upgrade for a WinForms application and am going to make it a Blazor app. The legacy app configuration is made using WinForm's PropertGrid. Is there an equivalent Blazor component or best practice for converting a settings class into a Blazor form?
e.g.
class MySettings{
public string Name {get;set;}
public int Age {get;set;}
public string Address {get;set;}
// 1000 other settings of int, string, enums etc
}
Is there a way to render MySettings into a nice Blazor form, or a Blazor component that can be used without designing the form in a Razor page with thousands of inputs binded to each property in MySettings.
This is the long form way of doing it with validation:
<EditForm Model="@_mySettingsModel" OnValidSubmit="HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<InputText id="name" @bind-Value="_mySettingsModel.Name" />
<InputText id="age" @bind-Value="_mySettingsModel.Age" />
<InputText id="address" @bind-Value="_mySettingsModel.Address" />
<button type="submit">Submit</button>
</EditForm>
@code {
private MySettings _mySettingsModel = new MySettings();
private void HandleValidSubmit()
{
Console.WriteLine("Saving Settings...");
}
}
Reference: https://docs.microsoft.com/en-us/aspnet/core/blazor/forms-validation?view=aspnetcore-3.1


