Events in .NET MAUI Chips
23 Apr 20252 minutes to read
SelectionChanging Event
The SelectionChanging event is triggered before the Chip is selected. You can restrict a chip from being selected, by canceling this event, by setting Cancel property in the event argument to true. The argument contains the following information,
- [AddedItem] - Used to get the selected chip from
SfChipGroup. - [RemovedItem] - Used to get the previous selected or deselected chip from
SfChipGroup. - [Cancel] - Used to set the value indicating whether the selection should be canceled.
SelectionChanged Event
The SelectionChanged event triggered after a chip is selected. The argument contains the following information,
- [AddedItem] - Get the selected chip from
SfChipGroup. - [RemovedItem] - Get the previous selected or deselected chip from
SfChipGroup.
NOTE
Currently,
ChoiceandFiltertypes are only supported forSelectionChangingandSelectionChangedevents.
ChipClicked
The ChipClicked event is triggered when a chip clicked in the [SfChipGroup]. The event argument is type of EventArgs.
ItemRemoved Event
The ItemRemoved event is triggered after the chip is removed from SfChipGroup. The argument contains the following information,
- [RemovedItem] - Get the removed chip item from the
SfChipGroup.
NOTE
The [ItemRemoved] event is supported only in the
Inputtype.
CloseButtonClicked
The CloseButtonClicked event is triggered when the closed button is clicked. The event argument is type of EventArgs.
<chip:SfChip x:Name="chip"
ShowCloseButton="True"
Text="John"
CloseButtonClicked="SfChip_CloseButtonClicked"/>SfChip chip = new SfChip();
chip.Text = "John";
chip.ShowCloseButton = true;
chip.CloseButtonClicked+=chip_CloseButtonClicked;private async void SfChip_CloseButtonClicked(object sender, EventArgs e)
{
await DisplayAlert("Message", "Chip CloseButton Clicked", "close");
}