user3796130
user3796130

Reputation:

How to change background color of AppBar Windows Phone 8.1

This is my code XAML, i just want to change background color of the labels and buttons inside

<Page.BottomAppBar>
    <CommandBar Background="#FF3965FF">
        <AppBarButton Label="estação" Icon="Map" Click="Bar_Localizar" Foreground="White" BorderBrush="White" Background="White"/>

        <CommandBar.SecondaryCommands>
            <AppBarButton Label="traçar rotas" Icon="Add" Click="bar_tracar_rotas" Foreground="White"/>
            <AppBarToggleButton Label="tráfego"  Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked"/>
            <AppBarToggleButton Label="mapa aéreo"  Checked="mapa_checked" Unchecked="mapa_unchecked"/>
            <AppBarButton Label="voltar" Icon="Add" Click="bar_voltar"/>
            <AppBarButton Label="Sair" Icon="Add" Click="bar_sair"/>
        </CommandBar.SecondaryCommands>
    </CommandBar>
</Page.BottomAppBar>

I try to use Foreground="White" but doesn't works!

Upvotes: 0

Views: 920

Answers (1)

Romasz
Romasz

Reputation: 29792

The AppBar is system UI and you are not allowed to change colors of individual buttons. If you want you can change the backgrounf color of whole application bar (use Background property) and color of all buttons (use Foreground property). This should work:

<Page.BottomAppBar>
  <CommandBar Background="#FF3965FF" Foreground="White">
    <AppBarButton Label="estação" Icon="Map" Click="Bar_Localizar"/>
  </CommandBar>
</Page.BottomAppBar>

Remember also to perform suitable changes for all themes (Light/Dark/Contrast) allowed by your app.

If you need something more customizable, then probably you will have to build own control that will mimic the AppBar.

Upvotes: 2

Related Questions