我正面临 MudSelect 的问题MultiSelect="true"
。即使它设置了选定的值,它也不会检查选定的值:
<MudSelect Label="Select Item" SelectAll="true" MultiSelection="true" SelectedValues="@SelectedTestItems" T="@MultiSelectItem" ToStringFunc="@ToString">
@foreach (MultiSelectItem item in AllItems)
{
<MudSelectItem Value="@item" />
}
</MudSelect>
@code {
private List<MultiSelectItem> SelectedTestItems = new() {
new MultiSelectItem{Id = 1, Name = "Test 1"},
};
private List<MultiSelectItem> AllItems = new() {
new MultiSelectItem{Id = 1, Name = "Test 1"},
new MultiSelectItem{Id = 2, Name = "Test 2"},
new MultiSelectItem{Id = 3, Name = "Test 3"},
new MultiSelectItem{Id = 4, Name = "Test 4"},
};
private string ToString(MultiSelectItem x)
=> x is null ? string.Empty : $"{x.Name}";
public class MultiSelectItem
{
public int Id { get; set; }
public string Name { get; set; }
}
}
我还发布了@github 的详细信息:https ://github.com/MudBlazor/MudBlazor/discussions/3532 。