question

robinrluther avatar image
0 Votes"
robinrluther asked ·

Remove AutoCorrect from SearchBar Xamarin.Forms

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.

dotnet-xamarinforms
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ColeXia-MSFT avatar image
0 Votes"
ColeXia-MSFT answered ·

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.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.