Events

RadAutoComplete component exposes the following events:

  • SuggestionItemSelected - occurs when an item is selected from the SuggestionsView. The SuggestionItemSelected event handler receives two parameters:

    • The sender argument which is of type object, but can be cast to the RadAutoComplete type.
    • An SuggestionItemSelectedEventArgs object which has a reference to the selected item through its DataItem property.
  • FilteredItemsChanged - occurs when the FilteredItems collection is updated. The FilteredItemsChanged event handler receives two parameters:

    • The sender argument which is of type object, but can be cast to the RadAutoComplete type.
    • An FilteredItemsChangedEventArgs object which has a reference to filtered items collection its FilteredItems property.

Example

Add the telerikInput namespace:

xmlns:telerikInput="clr-namespace:Telerik.XamarinForms.Input;assembly=Telerik.XamarinForms.Input"

Add a RadAutoComplete with the event handlers:

<telerikInput:RadAutoComplete x:Name="radAutoComplete" 
                              FilteredItemsChanged="RadAutoComplete_OnFilteredItemsChanged" 
                              SuggestionItemSelected="RadAutoComplete_OnSuggestionItemSelected" />

In code-behind, assign an ItemsSource and define the event handlers:

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();

        radAutoComplete.ItemsSource = new ObservableCollection<string>
        {
            "Apple",
            "Pear",
            "Cherry"
        };
    }

    private void RadAutoComplete_OnFilteredItemsChanged(object sender, FilteredItemsChangedEventArgs e)
    {
        // Since the ItemsSource is of type ObservableCollection<string>, FilteredItems will be as well.
        var filteredFruits = e.FilteredItems as ObservableCollection<string>;
    }

    private void RadAutoComplete_OnSuggestionItemSelected(object sender, SuggestionItemSelectedEventArgs e)
    {
        // The DataItem is an item from the FilteredItems collection. In this example, it's of type string.
        var selectedFruit = e.DataItem as string;
    }
}

See Also

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy