我试图将SearchBar添加到TitleView,以便SearchBar占用TitleBar的整个宽度,而不用硬编码width属性(WidthRequest)。但是SearchBar会以最小的所需宽度显示,并且不会占据整个宽度。有谁知道如何实现?
我正在使用的代码:
val firstName: String = "".empty()
val firstName: String = "".EMPTY
答案 0 :(得分:0)
尝试将SearchBar包裹在StackLayout中,就像这样
<NavigationPage.TitleView>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<SearchBar HorizontalOptions="FillAndExpand"/>
</StackLayout>
</NavigationPage.TitleView>