RadAutoComplete control has been replaced with RadAutoCompleteView and will be removed from the suite soon. You can read about the differences between both components and how to migrate to the new RadAutoCompleteView in the kb article here: Replace AutoComplete with AutoCompleteView

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

In this article
Not finding the help you need? Improve this article