2

I have recently added Jeff Wilcox's PhoneThemeManager to my app, which works great, although I am having problems changing the application bar buttons to the color I wish to use. My app design specifications require using the Light Theme. The problem I am having is that when the device is already in light theme, upon application loading the appbar foreground is the correct color because the PhoneThemeManager does not overwrite any values, although when in dark theme the appbar foreground values are black (which mimics the default foreground settings in the light theme).

According to his website, "If you have code in your app like “var ab = new ApplicationBar”, beware that that application bar will take on the system’s actual theme colors by default, and not the overridden light/dark coloring that happens with the app.

If you need to new up an ApplicationBar, you should use the convenience method of ThemeManager.CreateApplicationBar() or use the extension method on app bar that I added, MatchOverriddenTheme, to set the color values."

I'm not sure how to implement this to get custom appbar button colors.

I've done the following

public App()
{
// Global handler for uncaught exceptions. 
UnhandledException += Application_UnhandledException;

// Standard Silverlight initialization
InitializeComponent();

// Phone-specific initialization
InitializePhoneApplication();

ThemeManager.ToLightTheme();

// Other code that might be here already...
}

And in my MainPage appbar I wish to change the buttons accordingly

private void BuildLocalizedApplicationBar()
    {
        // Set the page's ApplicationBar to a new instance of ApplicationBar.
        ApplicationBar = new ApplicationBar();

        ApplicationBar.ForegroundColor = Color.FromArgb(255, 35, 85, 155);

        //Not sure where or how to use this?
        ApplicationBar.MatchOverriddenTheme(); //to override ThemeManager defaults

        //Create appbar buttons
        ...
    }

Any ideas?

Matthew
  • 3,976
  • 15
  • 66
  • 130

0 Answers0