1

I checked the Application bar but no style attribute is shown. I have about 10 pages that use an app bar so it would be ideal to set a style in the Application.Resources. Is it possible to apply a style to all application bars in my application?

ctacke
  • 66,480
  • 18
  • 94
  • 155
Edward
  • 7,346
  • 8
  • 62
  • 123

2 Answers2

2

You can pretty much do this with a abstract class which your pages inherit from.

public abstract class BasePage : PhoneApplicationPage
    {
        public abstract bool UsingApplicationBar { get; }

        public Color ApplicationBarColor= Colors.Gray;

    public BasePage()
    {
        Loaded += BasePageLoaded;

    }

    private void BasePageLoaded(object sender, RoutedEventArgs e)
    {
        if (UsingApplicationBar)
        {
            ApplicationBar.BackgroundColor = ApplicationBarColor;
        }

    }
}
William Melani
  • 4,270
  • 1
  • 21
  • 44
1

As far as I understand your question, you have different application bars on different pages and you want to have a style which can be applied to all. Unfortunately, binding does not work with application bars. You may have to style all of them one by one. For more information: Windows Phone ApplicationBar BackgroundColor property style XamlParseException

Community
  • 1
  • 1
Divya
  • 2,594
  • 1
  • 17
  • 29
  • Ok I see. I hope that changes in the future. Thanks for the quick response. I'll check your answer as accepted as soon as it lets me. – Edward Jan 12 '12 at 14:30