Remove AutoCorrect from SearchBar Xamarin.Forms

robinrluther 11 Reputation points
2021-03-21T13:22:19.45+00:00

My scenario is: Xamarin forms, mvvm with search bar. The Text property drives the search, as it changes, the search command is called:

<SearchBar x:Name="searchBar"  IsSpellCheckEnabled="False"  Grid.Row="0" SearchCommand="{Binding SearchEventsCommand}" Text="{Binding SearchTerm}"></SearchBar>

A user may enter "GI" and find a result in a list for "Giraffe". Then select the item in the list to view details. When they return to the full list screen, "GI" has been changed to "HI" by AutoCorrect and the results no longer reflect the original search.

Would like to be able to turn off auto correct in the Searchbar.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,295 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-03-22T05:14:29.773+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Take a look at KeyboardFlags , we can customize the Keyboard behavior in xaml like below

       <SearchBar   
           x:Name="SearchBar"  
           Placeholder="Search for a business..."  
           HorizontalTextAlignment="Start"  
           SearchCommand="{Binding PerformSearch}"  
           SearchCommandParameter="{Binding Text, Source={x:Reference SearchBar}}">  
           <SearchBar.Keyboard>  
               <Keyboard x:FactoryMethod="Create">  
                   <x:Arguments>  
                       <KeyboardFlags>None</KeyboardFlags>  
                   </x:Arguments>  
               </Keyboard>  
           </SearchBar.Keyboard>  
       </SearchBar>  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.
    0 comments No comments