Reputation: 83
I am using MudBlazor for a Blazor project. I am trying to create a multiselect component using Enums. I have it working so that the component shows and the selections being chosen correctly. The issues are coming up with the actual display of the component. First of all, even if nothing has been chosen, the first entry's text is being displayed which overlaps the label given to the component. Secondly, once I choose different components, the text does not update even though I have the MultiSelectionTextFunc set and when debugging, I see that the called function is producing the correct text. Here is a link to the demo: https://try.mudblazor.com/snippet/GOwIYdloqAKBdPcl
I just want to figure out how to resolve the overlapping text and why my text is not updating.
Upvotes: 1
Views: 588
Reputation: 11392
You have to use T="Color?"
instead of T="Color"
:
@using Try.UserComponents
<MudSelect T="Color?" Label="Choose a color" MultiSelection="true" SelectAll="true" SelectAllText="Select All" @bind-SelectedValues="SelectedColors" AdornmentIcon="@Icons.Material.Filled.Search" AnchorOrigin="Origin.BottomCenter">
<MudSelectItem T="Color?" Value="Color.Red">Red</MudSelectItem>
<MudSelectItem T="Color?" Value="Color.Blue">Blue</MudSelectItem>
<MudSelectItem T="Color?" Value="Color.LightBlue">Light Blue</MudSelectItem>
</MudSelect>
@code {
private IEnumerable<Color?> SelectedColors { get; set; } = new HashSet<Color?>();
}
https://try.mudblazor.com/snippet/mYGSkxlyKBgQuJlK
Upvotes: 1