Xamarin在XAML中形成应用程序外壳背景色底部标签

时间:2019-08-25 20:40:22

标签: forms shell xaml xamarin tabs

我正在尝试更改底部标签的背景颜色,但这不起作用:
我使用最新版本的xamarin表单,并制作了一个shell应用。
在appshell xaml中,我将背景色更改为其他颜色,但是当我启动该应用程序时,没有任何改变。
我希望有人可以向我解释如何更改背景颜色。

1 个答案:

答案 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}" />

enter image description here

注意:在官方文档中,有一个sample供参考。