我正在尝试将SearchBar添加到TitleView中,以便SearchBar采用TitleBar的全宽度,而无需硬编码宽度属性(WidthRequest)。但SearchBar以所需的最小宽度显示,而不是全宽。有谁知道如何实现这一目标吗?
我使用的代码如下:
var searchBar = new SearchBar
{
Placeholder = "Search",
HorizontalOptions = LayoutOptions.FillAndExpand
};
NavigationPage.SetTitleView(this, searchBar);发布于 2018-09-28 05:16:32
尝试将SearchBar包装在StackLayout中,如下所示
<NavigationPage.TitleView>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<SearchBar HorizontalOptions="FillAndExpand"/>
</StackLayout>
</NavigationPage.TitleView>https://stackoverflow.com/questions/52542775
复制相似问题