Events and Interactivity in Xamarin SfComboBox

22 Aug 20223 minutes to read

ValueChanged Event

You can perform operation, while changing the value of SfComboBox Text using the ValueChanged event. ValueChanged event returns the changed value in SfComboBox.

The ValueChanged event returns the following argument.

Members Description
Value Displays changed value in SfComboBox

SelectionChanged Event

The SelectionChanged event is used to notify when an item is selected from the suggestion list or when dynamically setting the SelectedIndex property of SfComboBox, the event is triggered. For more information, refer to this link. The SelectionChanged event returns the following argument.

Members Description
Value Holds the selected items in SfComboBox

SelectionChanging Event

The SelectionChanging event is used to notify, before the selection is going to changed by tapping the suggestion box or dynamically setting the SelectedIndex property of SfComboBox.The SelectionChanged event returns the following argument.

Members Description
Value Holds the selecting items in SfComboBox.
Cancel Restricts the item to be selected.

FocusChanged Event

The FocusChanged event occurs when the control gets the focus and loses the focus. The argument contains the following information.

Members Description
HasFocus Indicates whether the control is in focused state or not.

FilterCollectionChanged Event

The FilterCollectionChanged event is triggered whenever the items gets filtered in the suggestion.

For more information regarding this refer to this link. The FilterCollectionChanged event returns the following argument.

Members Description
Value Holds the filtered items in the suggestion.

The DropDownOpen event occurs when the SfComboBox drop-down is opened.

The DropDownClosing event occurs when the drop-down closes.

IsItemSelected - It returns the value indicating whether the item is selected or not when the dropdown window closes.

Cancel - Closing of the dropdown can be handled by setting the e.Cancel.

<combobox:SfComboBox HeightRequest="40"
                             x:Name="comboBox"
                             DataSource="{Binding EmployeeCollection}"
                             DropDownClosing="SfComboBox_DropDownClosing"
                             DisplayMemberPath="Name"
                             />
public MainPage()
     {
       InitializeComponent();
       comboBox.DropDownClosing += SfComboBox_DropDownClosing;
     }

     private void SfComboBox_DropDownClosing(object sender, DropDownCancelEventArgs e)
     {
            if (e.IsItemSelected)
            {
                e.Cancel = true;
            }
            else
            {

                e.Cancel = false;
            }
     }

The DropDownClosed event occurs when the SfComboBox drop-down is closed.

Completed Event

The Completed event is raised when the user finalizes the text in the SfComboBox editable mode by pressing return key on the keyboard.

Tapped Event

The Tapped event occurs when the SfComboBox is tapped in Non-editable mode.

LoadMoreButtonTapped Event

The LoadMoreButtonTapped can be triggered only when you tap on the load more button. For more information, refer to this link.