Customizing the Suggestion DropDown

2 Jul 20193 minutes to read

The suggestion list displaying behavior can be customized based on the entered text and delays in displaying the items.

Set Minimum Prefix Character

Instead of displaying suggestion list on every text entry, the most possible match can be filtered and displayed after few text entries. This can be done by modifying MinimumPrefixCharacters.

NOTE

The default property value is 1.

countryAutoComplete.MinimumPrefixCharacters = 4;

Minimum prefix character

Set PopUp Delay

We can delay the time taken to display the dropdown with suggestion list by using the PopUpDelay property in SfAutoComplete .

NOTE

The default value is 0. The property value is maintained in milliseconds.

countryAutoComplete.PopUpDelay = 100;

Set Maximum Height to the DropDown

The height of the drop-down portion of the SfAutocomplete control can be varied using MaximumDropDownHeight property.

NOTE

The MaximumDropDownHeight value can be any positive integer value.

countryAutoComplete.MaximumDropDownHeight = 200;

Maximum drop down height

Set border color to the DropDown

The DropDownBorderColor property is used to change the border color of DropDown. The following code example demonstrates how to change the border color of DropDown.

LinearLayout linearLayout = new LinearLayout(this);
            linearLayout.LayoutParameters = new ViewGroup.LayoutParams(1000, ViewGroup.LayoutParams.MatchParent);
            linearLayout.SetBackgroundColor(Android.Graphics.Color.Transparent);

            SfAutoComplete countryAutoComplete = new SfAutoComplete(this);
            countryAutoComplete.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, 50);

            List<String> countryList = new List<String>();
            countryList.Add("Uganda");
            countryList.Add("Ukraine");
            countryList.Add("United Arab Emirates");
            countryList.Add("United Kingdom");
            countryList.Add("United States");

            ArrayAdapter<String> countryListDataAdapters = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, countryList);
            countryAutoComplete.AutoCompleteSource = countryListDataAdapters;
            countryAutoComplete.DropDownBorderColor = Color.Red;
            countryAutoComplete.MaximumDropDownHeight = 200;

            linearLayout.AddView(countryAutoComplete);
            SetContentView(linearLayout);

Dropdown border color