我需要将 @bind-SelectedValues 绑定到 ductionary 中的值。但它给出了 CS1503 参数 2:无法从 'Microsoft.AspNetCore.Components.EventCallback<System.Collections.Generic.List>' 转换为 'Microsoft.AspNetCore.Components.EventCallback'
<MudTable Items="users.UserList" Loading="@_loading" LoadingProgressColor="Color.Info">
<HeaderContent>
<MudTh>User</MudTh>
<MudTh>Applications</MudTh>
<MudTh>Edit</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="User">@context.FullName</MudTd>
<MudTd DataLabel="Application">
<MudSelect Variant="Variant.Outlined" T="int" Label="Applications" MultiSelection="true"
@bind-Value="value"
@bind-SelectedValues="userAppsDict[context.Id]">
@foreach(var item in apps.ApplicationList)
{
<MudSelectItem T="int" Value="@item.Id">@item.Name</MudSelectItem>
}
</MudSelect>
</MudTd>
<MudTd>
<MudButton Color="Color.Primary" Variant="Variant.Filled">Update</MudButton>
</MudTd>
</RowTemplate>
</MudTable>
@code{
[Inject]
private IApplicationService service{ get; set; }
private int value { get; set; }
private IEnumerable<int> options { get; set; } = new HashSet<int>();
private bool _loading = false;
private Dictionary<int, List<int>> userAppsDict { get; set; } = new Dictionary<int, List<int>>();
UserHasApplicationsReadViewModel userApps = new UserHasApplicationsReadViewModel();
UserReadViewModel users = new UserReadViewModel();
ApplicationReadViewModel apps = new ApplicationReadViewModel();
protected override async Task OnInitializedAsync()
{
_loading = true;
userApps = await service.GetUserHasApplications();
users = await service.GetUsers();
apps = await service.GetApplicationsAsync();
foreach(var user in users.UserList)
{
List<int> appIdList = new List<int>();
var appsbyUid = await service.GetApplicationByUserId(user.Id);
foreach (var item in appsbyUid.ApplicationList)
{
appIdList.Add(item.Id);
}
userAppsDict.Add(user.Id, appIdList);
}
Console.WriteLine(JsonSerializer.Serialize(userAppsDict));
_loading = false;
}
}