I'm trying to figure out why the checkbox values are cleared when other inputs are changed or clicked
layout snippet
<RadzenColumn>
<RadzenRow Gap="0rem">
<RadzenTextBoxWithLabel Label="Client" Name="Client" Layout="@InputLayout.Horizontal"
@bind-Value="@AddOrEditContact.ClientName" Placeholder="Client" IsRequired="false" Disabled="true" ReadOnly="true" />
</RadzenRow>
<RadzenRow Gap="0rem" class="p-1">
<RadzenTextBoxWithLabel Label="Title" Name="Title" Layout="@InputLayout.Horizontal"
@bind-Value="@AddOrEditContact.Title" Placeholder="Title (optional)" IsRequired="false" />
</RadzenRow>
</RadzenColumn>
<RadzenColumn>
<RadzenRow Gap="0rem" class="p-1">
<RadzenColumn>
<RadzenRow Gap="0rem">
<RadzenCheckBoxWithLabel Label="Primary" Name="Primary" Layout="@InputLayout.Horizontal" LabelColClass="col-md-7"
TValue="bool" @bind-Value="@AddOrEditContact.Primary" Placeholder="Preferred Name" IsRequired="false" />
</RadzenRow>
</RadzenColumn>
<RadzenColumn>
<RadzenRow Gap="0rem">
<RadzenCheckBoxWithLabel Label="Email Undeliverable" Name="EmailUndeliverable" Layout="@InputLayout.Horizontal" LabelColClass="col-md-7"
TValue="bool" @bind-Value="@AddOrEditContact.EmailUndeliverable" IsRequired="false" />
</RadzenRow>
</RadzenColumn>
</RadzenRow>
</RadzenColumn>
Custom component code
RadzenCheckBoxWithLabel
@using ComponentLibrary.Blazor.Enums;
@inherits RadzenCheckBox<TValue>
@typeparam TValue
@switch (Layout)
{
case InputLayout.Horizontal:
<div class="@LabelColClass">
<RadzenLabel Text="@Label" />
</div>
<div class="col">
<RadzenCheckBox @bind-Value=@Value Name="@Name" TValue="@TValue" Disabled="@Disabled" />
@if (IsRequired)
{
<RadzenRequiredValidator Component="@Name" Text=@($@"{@Label} is required") Popup=@Popup Style="position: absolute" />
}
</div>
break;
case InputLayout.Vertical:
<RadzenColumn class="rz-p-1">
<RadzenRow Gap="0">
<div class="@LabelColClass">
<RadzenLabel Text="@Label" />
</div>
</RadzenRow>
<RadzenRow Gap="0">
<div class="col">
<RadzenCheckBox @bind-Value=@Value Name="@Name" TValue="@TValue" Disabled="@Disabled" />
@if (IsRequired)
{
<RadzenRequiredValidator Component="@Name" Text=@($@"{@Label} is required") Popup=@Popup Style="position: absolute" />
}
</div>
</RadzenRow>
</RadzenColumn>
break;
case InputLayout.Testing:
break;
default:
throw new ArgumentOutOfRangeException();
}
@code {
[Parameter]
public bool IsRequired { get; set; }
[Parameter]
public InputLayout Layout { get; set; }
[Parameter]
public bool Popup { get; set; } = true;
[Parameter]
public string Label { get; set; } = " No Label set";
[Parameter]
public string LabelColClass { get; set; } = "col-md-4";
}