@inject IDataService DataService Avatar Id Avatar Name @{ # pragma warning disable CS8602 } @context.AvatarId @context.AvatarName @{ # pragma warning restore CS8602 } Selected Title: @selectedAvatar?.AvatarName Cancel Ok @code{ [CascadingParameter] public required MudDialogInstance MudDialog { get; set; } [Parameter] public required PlayOptionData Data { get; set; } private Avatar? selectedAvatar; private IReadOnlyList avatars = new List(); private string searchString = string.Empty; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); selectedAvatar = DataService.GetAvatarById((uint)Data.OptionPart1.AvatarId); avatars = DataService.GetAvatarsSortedById(); } private bool Filter(Avatar? avatar) { if (avatar is null) { return false; } return string.IsNullOrEmpty(searchString) || avatar.AvatarName.Contains(searchString, StringComparison.OrdinalIgnoreCase); } private void Submit() { if (selectedAvatar is not null) { Data.OptionPart1.AvatarId = (int)selectedAvatar.AvatarId; } MudDialog.Close(DialogResult.Ok(true)); } private void Cancel() => MudDialog.Cancel(); }