Events

25 Jun 20193 minutes to read

The Events in SfAutoComplete are:

  • FocusChanged

  • SelectionChanged

  • SelectionChanging

  • TextChanged

  • FilterCollectionChanged

FocusChanged

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.
autocomplete.FocusChanged += Autocomplete_FocusChanged;

 void Autocomplete_FocusChanged(object sender, FocusEventArgs e)
        {
            if (e.HasFocus)
            {
                DisplayAlert("Alert", "Focus", "Ok");
            }
            else
            {
                DisplayAlert("Alert", "UnFocus", "Ok");
            }
        }

SelectionChanged

The SelectionChanged event is triggered after selecting an item among the filtered suggestions in SfAutoComplete.

The SelectionChanged event returns the following arguments:

Members Description
AddedItems Shows recently added item in AutoComplete.
RemovedItems Shows recently removed items in AutoComplete.
Value Holds all selected items in AutoComplete.
autocomplete.SelectionChanged += Autocomplete_SelectionChanged;

 void Autocomplete_SelectionChanged(object sender, SelectionEventArgs e)
 {

 DisplayAlert("Alert", "Item Selected", "Ok");

 }

SelectionChanging

The SelectionChanging event is triggered when you select an item among the filtered suggestions in SfAutoComplete.

The SelectionChanging event returns the following argument:

Members Description
Value Holds all selecting items in AutoComplete.
Cancel Restricts the item to be selected.
autocomplete.SelectionChanging += Autocomplete_SelectionChanging;

 void Autocomplete_SelectionChanging(object sender,SelectionChanging EventArgs e) 
 {

 DisplayAlert("Alert", "Selection Changing", "Ok");

 }

TextChanged

The TextChanged event is triggered when you change the text of SfAutoComplete.

The TextChanged event returns the following argument:

Members Description
Value Holds the text of AutoComplete.
autocomplete.TextChanged += Autocomplete_TextChanged;

 void Autocomplete_TextChanged(object sender, TextEventArgs e)
 {

 DisplayAlert("Alert", "Text Changed", "Ok");

 }

FilterCollectionChanged

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

The FilterCollectionChanged event returns the following argument:

Members Description
Value Holds the filtered items in the suggestion.
autocomplete.FilterCollectionChanged += Autocomplete_FilterCollectionChanged;

 void Autocomplete_FilterCollectionChanged(object sender, FilterCollectionChangedEventArgs e)
 {
 
 DisplayAlert("Alert", "FilterCollectionChanged", "Ok");
  
 }