Articles in this section

How to avoid capitalizing inputted characters while adding Text in the middle of two words?

The Syncfusion autocomplete in Xamarin provides a simpler way to complete the text based on the characters that the user has entered before.

This section explains how to avoid the capitalizes inputted characters while adding text in the middle of two words in iOS.

Step 1: Create an SfAutoComplete sample with all the necessary assemblies. Refer to this Getting Started documentation to create a simple SfAutoComplete sample and configure it.

Step 2: Create a CustomAutocomplete control by subclassing the SfAutoComplete control.

public class CustomAutocomplete: SfAutoComplete

{

 

 }

 

Step 3: Initialize the CustomAutocomplete in XAML page with the properties need to be assigned and added the items to the autocomplete as shown in the following code snippet.

<StackLayout VerticalOptions="Start" HorizontalOptions="Start" Padding="30">
        <local:CustomAutocomplete HeightRequest="40" x:Name="autoComplete">
            <local:CustomAutocomplete.AutoCompleteSource>
                <ListCollection:List x:TypeArguments="x:String">
                    <x:String>Great Britain</x:String>
                    <x:String>Uganda</x:String>
                    <x:String>South Africa</x:String>
                    <x:String>United States of America</x:String>
                    <x:String>New Zealand</x:String>
                    <x:String>Italy</x:String>
                    <x:String>United Kingdom</x:String>
                    <x:String>China</x:String>
                    <x:String>Japan</x:String>
                </ListCollection:List>
            </local:CustomAutocomplete.AutoCompleteSource>
        </local:CustomAutocomplete>
</StackLayout>
 

 

Step 4: In native iOS, inputted characters are capitalized while adding text in the middle of two words and this seems to be the behavior. You can avoid this by adding the AutoCapitalizationType to None as follows.

 

public class CustomAutocompleteRenderer : SfAutoCompleteRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Syncfusion.SfAutoComplete.XForms.SfAutoComplete> e)
        {
            base.OnElementChanged(e);
            if (this.Control != null)
            {
                Control.TextField.AutocapitalizationType = UITextAutocapitalizationType.None;
            }
        }
    }

 

You can find the sample in the following link

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied