RadzenListBox won't let me select items

Something here is breaking the RadzenListBox and I have no idea what; the checkboxes can't be checked but I get no errors to indicate anything is wrong. The list populates and looks correct other than the checkboxes not working.

        <!--This one works, I just put it in to try and figure out what was wrong -->
<RadzenListBox AllowFiltering="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" @bind-Value=@selectedWorkQueues 
                       Multiple="true" Data=@deleteMe TextProperty="Name" ValueProperty="ModelKey" TValue="IEnumerable<Guid>"/>
        <!--actual desired code that doesn't work -->
        @foreach (Project project in ProjectList.Except(new[] {CurrentProject}).ToList())
        {
            var workQueueList = OtherProjectsWorkQueues[project.ModelKey];
            if (workQueueList.ActiveQueues.Any())
            {
                <MudText>@project.Name</MudText>
                <RadzenListBox AllowFiltering="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" @bind-Value=@selectedWorkQueues 
                               Multiple="true" Data=@workQueueList.ActiveQueues TextProperty="Name" ValueProperty="ModelKey" TValue="IEnumerable<Guid>"/>
            }
        }
private IEnumerable<Guid> selectedWorkQueues = new List<Guid>();
private List<WorkQueue> deleteMe = new List<WorkQueue>{new WorkQueue{Name = "a", ModelKey = new Guid()}};

In case anyone was wondering, workQueueList.ActiveQueues returns a List<WorkQueue> so it's the same type as the deleteme var.

Hi @hamdawg87,

Try changing the type of selectedWorkQueues to IList<Guid>

1 Like

Thanks, now the checkboxes work and I have an actual error message to figure out what else is wrong.

Edit: I guess I celebrated too soon, the error message I got was not any easier to solve than the original problem.
What I changed the code to:

<RadzenListBox AllowFiltering="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" @bind-Value=selectedWorkQueues
               Multiple="true" Data=@workQueueList.ActiveQueues TextProperty="Name" ValueProperty="ModelKey" TValue="IList<Guid>"/>

and the c#:

private IList<Guid> selectedWorkQueues;

Error message:

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Specified cast is not valid.
System.InvalidCastException: Specified cast is not valid.
   at Radzen.DropDownBase`1.<SelectItem>d__86[[System.Collections.Generic.IList`1[[System.Guid, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at Radzen.DropDownBase`1.<SelectItemInternal>d__85[[System.Collections.Generic.IList`1[[System.Guid, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at Radzen.Blazor.RadzenListBoxItem`1.<<BuildRenderTree>b__0_0>d[[System.Collections.Generic.IList`1[[System.Guid, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

I should also note that on a different page I got it working with IEnumerable<int>, so now I'm thinking maybe that only works for primitives and you have to use an actual list otherwise.

Bumping because this is still broken with no response in last 24 hours.

Hi @hamdawg87

If you have a Radzen professional subscription you can send us your project to info@radzen.com

We don't have a subscription and we're not going to get one. All I know is that it's something in the compiler generated method of yours that's doing an invalid cast. I can't see the code, so I can't possibly fix it. Guess I'll find a different library or write my own solution from scratch.

dropDownBase.Value = (object) dropDownBase.selectedItems.Select<object, object>(new Func<object, object>(dropDownBase.\u003CSelectAll\u003Eb__43_0)).AsQueryable<object>().Cast(property.PropertyType);