Search code examples
xamlwindows-phone-7application-bar

Windows Phone ApplicationBar BackgroundColor property style XamlParseException


I had a lot of pages in my application and I had decided to make a global ApplicationBar style in App.Resources:

<Style TargetType="shell:ApplicationBar">
    <Setter Property="BackgroundColor" Value="#006699" />
</Style>

However, when I tried to start the app, VS gave me an error:

The property 'BackgroundColor' was not found in type 'Microsoft.Phone.Shell.ApplicationBar'.

This isn't true - ApplicationBar.BackgroundColor Property. What's the problem?


Solution

  • I believe, ApplicationBar properties cannot use Binding or styling the way you're trying, as it is not a silverlight control. Although you can put the whole applicationbar as a resource. Like so

    <shell:ApplicationBar x:Key="MyAppBar" IsVisible="True" BackgroundColor="#006699">
             <shell:ApplicationBarIconButton IconUri="/Images/image.png" Text="image"  IsEnabled="True"/>  
    </shell:ApplicationBar>
    

    EDIT: Or you could just put this in the resource if you want your application bar color to change.

    <shell:ApplicationBar x:Key="MyAppBar" IsVisible="True" BackgroundColor="#006699">
    </shell:ApplicationBar>
    

    And add buttons from code behind. although, I haven't come across a scenario where this would help.