如何解决SearchBar 右侧没有“X”按钮
如您所见,我的 SearchBar 没有“X”按钮,该按钮通常位于 SearchBar 的右侧。 我只在使用 Android 时遇到问题,iOS 有一个 X 和一个取消按钮。 我需要添加标签还是我做错了什么?
<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
解决方法
删除
NavigationPage.TitleView
或
StackLayout BackgroundColor="Red" HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" Orientation="水平"
如果 SearchBar 被 NavigationPage.TitleView 和 StackLayout 包围,则“X”按钮将消失。删除其中任何一个都可以解决问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。