Untitled

mail@pastecode.io avatar
unknown
csharp
a year ago
726 B
1
Indexable
Never
<MudChipSet 
    SelectedValues="_selectedChips"
    SelectedChipsChanged="CallbackChips"
    MultiSelection
    Filter
>
    <MudChip Text="Milk"></MudChip>
    <MudChip Text="Eggs"></MudChip>
</MudChipSet>

<div class="d-flex flex-column align-center">
    @if (_selectedChips is {Length: > 0 })
    {
        <MudText>You selected @string.Join(", ", _selectedChips.Select(chip => chip.Text)).</MudText>
    }
    else
    {
        <MudText>Nothing selected.</MudText>
    }
</div>

@code {
    private MudChip[] _selectedChips = { new () { Text = "Milk" } };
    
    private void CallbackChips(MudChip[] chips)
    {
        
        if (chips.Length == 0)
            return;
        _selectedChips = chips;
    }

}csha