New to Telerik UI for Xamarin? Download free 30-day trial

AutoCompleteTextView for Xamarin.iOS: Tokens

In order to provide better user expirience and complete set of functionalities TKAutoCompleteTextView supports text tokenizing which can be enabled through the DisplayMode property of the TKAutoCompleteTextView.

this.Autocomplete.DisplayMode = TKAutoCompleteDisplayMode.Tokens;
The layout flow of the tokens can be horizontal or vertically wrapped. This feature can be accessed through the layoutMode property of the TKAutoCompleteTextView. By default vertical wrapping is used.

this.Autocomplete.LayoutMode = TKAutoCompleteLayoutMode.Wrap;
Tokens appereance can be customized by conforming to the TKAutoCompleteDelegate protocol and implementing the ViewForToken method. You can change variaty of properties to get custom look or you can provide a custom token object.

class AutoCompleteTokensDelegate : TKAutoCompleteDelegate
{
    public override TKAutoCompleteTokenView ViewForToken(TKAutoCompleteTextView autocomplete, TKAutoCompleteToken token)
    {
        TKAutoCompleteTokenView tokenView = new TKAutoCompleteTokenView(token);
        tokenView.BackgroundColor = UIColor.LightGray;
        tokenView.Layer.CornerRadius = 10;
        tokenView.ImageView.Layer.CornerRadius = 3;
        return tokenView;
    }
}

AutoCompleteTextView Token demo can be found in our Native Xamarin.iOS examples.

In this article