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 Programatically add items to autocompletebox

Thread ID:





142713 Feb 15,2019 10:17 PM UTC Feb 20,2019 03:39 AM UTC Xamarin.Forms 1
Tags: SfAutoComplete
Minh Tran
Asked On February 19, 2019 02:37 PM UTC

I'm currently using the autocompletebox with multiselect. 

My current code


    autocomplete:SfAutoComplete MultiSelectMode="Token"
                                Text="{Binding Keyword, Mode=TwoWay }"
                                SelectedItem="{Binding SelectedKeywords, Mode=TwoWay}"
                                DataSource="{Binding Keywords}">


    public ObservableCollection Keywords
        get { return _keywords; }
        set { _keywords = value; OnPropertyChanged("Keywords"); }

    public ObservableCollectionSelectedKeywords
        get { return _selectedKeywords; }
        set { _selectedKeywords = value; OnPropertyChanged("SelectedKeywords"); }

    Keywords = new ObservableCollection() { "Apples" , "Bananas" ,  "Celery" } ;

The issue I'm coming across is that when tokens are selected on the app (if I were to select apple), SelectedKeywords is not updated, the count will remain zero. BUT if I were to change it to be of ObservableCollection<object><object> it works perfect.

The next issue I'm coming across is clearing SelectedKeywords<object>. I would like to also do the reverse, adding items to the SelectedKeywords, but the UI isn't reflected. 

Any assistance would be greatly appreciated. 

Selva Kumar  Veerakrishnan [Syncfusion]
Replied On February 20, 2019 03:39 AM UTC

Hi Minh, 

Greetings from Syncfusion. 

Query 1: When selecting the items in Token mode, selected item count is not updated correctly. 

We have created the SfAutoComplete sample in which we have updated the selected item count when the selection gets changed inside SelectionChanged event and the selected item counts updated correctly in Token mode. We have prepared the sample for your reference. Please download it from the below link. 

Query 2: After clearing the selected item and adding the selected item dynamically UI does not reflected. 

We have tried your requirement by clearing the existing item in the autocomplete and we have tried adding the selected item collection dynamically. The selected item updated in UI in android and in iOS we are facing the exception. We have provided the sample below. Please download it from the below link. 

Please try our sample and let us know you are facing the same issue in iOS. If not please modify the given sample and provide us with more details on which scenario you could reproduce the issue and it will help us work further with your requirement 

Selvakumar V 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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
Live Chat Icon