我正在尝试更改底部标签的背景颜色,但这不起作用:
我使用最新版本的xamarin表单,并制作了一个shell应用。
在appshell xaml中,我将背景色更改为其他颜色,但是当我启动该应用程序时,没有任何改变。
我希望有人可以向我解释如何更改背景颜色。
答案 0 :(得分:3)
查看此官方文档Xamarin.Forms Shell Page Configuration。您可以Styling Xamarin.Forms Apps using XAML Styles。
例如,如果要更改“标签栏”背景色,可以按如下方式设置样式:
<Shell.Resources>
<Style x:Key="BearsShell"
TargetType="Element"
BasedOn="{StaticResource BaseStyle}">
<Setter Property="Shell.TabBarBackgroundColor"
Value="#546DFE"/>
</Style>
</Shell.Resources>
然后您可以在Shell Content中设置样式:
<ShellContent Route="bears"
Style="{StaticResource BearsShell}"
Title="Bears"
Icon="bear.png"
ContentTemplate="{DataTemplate views:BearsPage}" />
注意:在官方文档中,有一个sample供参考。