We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to populate the items dynamically in suggestionlist in SfAutoComplete

Platform: Xamarin.Forms |
Control: SfAutoComplete

Auto complete provides support for populating the items dynamically in suggestion list.


To populate the items dynamically in suggestion list:

Step 1:   Add the required assemblies to get the view of AutoComplete.

Step 2: Provide a method in which you load the items to add in suggestion list, dynamically.

Step 3: Call that method inside the value changed event so that value in the suggestion list be updated whenever the change occurs in the entered value.


The following code illustrates how to achieve this method.


XAML code:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
            <autocomplete:SfAutoComplete x:Name="AutoComplete" 
                                     DataSource="{Binding AutoCompleteItems,Mode=TwoWay}" 


Code behind code:

namespace AutoComplete
public class AutoCompleteItem
    public int Id { get; set; }
    public string Label { get; set; }
public partial class MainPage : ContentPage
    private SfAutoCompletePageViewModel context;
    public MainPage()
        context = new SfAutoCompletePageViewModel();
        BindingContext = context;
    private void AutoComplete_OnSelectionChanged(object sender, Syncfusion.SfAutoComplete.XForms.SelectionChangedEventArgs e)
        var value = (e?.Value as AutoCompleteItem)?.Label;
        if (string.IsNullOrEmpty(value)) return;
    private void AutoComplete_OnValueChanged(object sender, Syncfusion.SfAutoComplete.XForms.ValueChangedEventArgs e)
        var text = e?.Value;
        if (string.IsNullOrEmpty(text)) return;



Code behind ViewModel code:

namespace AutoComplete
public class SfAutoCompletePageViewModel : INotifyPropertyChanged
    #region INotifyPropertyChanged Implementation
    public event PropertyChangedEventHandler PropertyChanged;
    void OnPropertyChanged([CallerMemberName] string propertyName = "")
        if (PropertyChanged == null) return;
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    private ObservableCollection<AutoCompleteItem> autoCompleteItems;
    public ObservableCollection<AutoCompleteItem> AutoCompleteItems { get { return autoCompleteItems; } set { autoCompleteItems = value; OnPropertyChanged(); } }
    public SfAutoCompletePageViewModel()
        AutoCompleteItems = new ObservableCollection<AutoCompleteItem>()
            new AutoCompleteItem()
                Id = 1,
                Label = "salut"
    public async Task RefreshAutoCompleteDataSourceItems(string text)
        var items = new ObservableCollection<AutoCompleteItem>();
        for (int i = 0; i < 10; i++)
            items.Add(new AutoCompleteItem()
                Id = i,
                Label = text + i
        AutoCompleteItems = items;


Image after the Value gets updated dynamically:

Populating the items dynamically in SfAutoComplete




2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile