John
John

Reputation: 3945

SearchBar doesnt have 'X' button on right hand side

As you can see my SearchBar doesn't have an 'X' button, which is normally at the right hand side of the SearchBar. I only have the issue using Android, iOS has an X and a cancel button. Do I need to add a tag in or what am I doing wrong?

enter image description here

 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="BottleShop.Views.Products">
        <NavigationPage.TitleView>
            <StackLayout BackgroundColor="Red" HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" Orientation="Horizontal">
                <SearchBar x:Name="Search" TextColor="Black" BackgroundColor="Purple" TextChanged="Searc_TextChanged" HorizontalOptions="FillAndExpand" Placeholder="Search..." PlaceholderColor="Gray" VerticalOptions="StartAndExpand"/>
            </StackLayout>
        </NavigationPage.TitleView>
        <ContentPage.ToolbarItems>
            <ToolbarItem Name="CartImage" Icon="ShoppingCart.png" Priority="0" Order="Primary" Activated="Clicked"/>
            <ToolbarItem Text="{Binding NoItemsInShoppingCart}" Priority="0" Activated="Clicked" Order="Primary"/>
        </ContentPage.ToolbarItems>

        <ContentPage.Content>
    

Xamarin.Forms v5.0.0.2012

Upvotes: 1

Views: 168

Answers (1)

Steven-MSFT
Steven-MSFT

Reputation: 8431

Remove

NavigationPage.TitleView

Or

StackLayout BackgroundColor="Red" HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" Orientation="Horizontal"

If the SearchBar surrounded by NavigationPage.TitleView and StackLayout, the 'X' button will disappear. Remove anyone of them can solve the problem.

enter image description here

Upvotes: 2

Related Questions