4

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?

Alec Mev
  • 4,663
  • 4
  • 30
  • 44

1 Answers1

2

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.

abhinav
  • 3,199
  • 2
  • 21
  • 25
  • Unfortunately, this won't solve my problem, because every ApplicationBar in my app has a different button and menu item set. If you are referring to the fact, that I can put all sets in one resource file - it will be somewhat easier to locate them, but amount of work in case I decide, for example, to change resource type of any property, won't be any smaller. Thanks for reminding, that it isn't a Silverlight control, though. It explains everything. – Alec Mev Nov 26 '11 at 17:40
  • I agree it will be quite cumbersome. Added another option which, depending on your situation, might help. – abhinav Nov 26 '11 at 17:45
  • Well, it is a universal solution, however my situation isn't so extreme :) I just was wondering, is there a WPF-way. Thanks. – Alec Mev Nov 26 '11 at 17:54