Why are the checkboxes still checkable?
@if (@GearTypeView.PickN > 1){ @foreach (GearView gearView in GearTypeView.GearViews) {<div class="row"><div class="col m-1"><input type="checkbox" checked="@IsChecked(gearView.GearId)" @onchange="(ChangeEventArgs args) => { OnGearChanged(args, gearView.GearId); }" /> @gearView.GearDescription</div></div> }}@code { [Parameter] public GearTypeView GearTypeView { get; set; } = new(); private List<int> selectedGearIds = new(); private void OnGearChanged(ChangeEventArgs args, int gearId) { bool isChecked = (Boolean)args.Value; if (isChecked && !selectedGearIds.Contains(gearId) && selectedGearIds.Count < GearTypeView.PickN) { selectedGearIds.Add(gearId); } else if (!isChecked && selectedGearIds.Contains(gearId)) { selectedGearIds.Remove(gearId); } } private bool IsChecked(int gearId) { bool isChecked = selectedGearIds.Contains(gearId); return isChecked; }}When I put a breakpoint at the end of OnGearChanged(), the list of checked checkboxes is being updated appropriately, including not allowing more than the max (called PickN). When I put a breakpoint at the end of IsChecked(), the evaluation returns the expected true/false. & every time a checkbox is clicked, IsChecked() is being called. I tried adding StateHasChanged() to the end of OnGearChanged(), but the same unexpected behavior is exhibited.
Thanks in advance!