简体   繁体   中英

ThemeManager.ToLightTheme() matching applicationbar

I'm trying to make an application with the default light theme but set the Application Bar background to yellow, so I downloaded the PhoneThemeManager from NuGet. Here is my code:

ThemeManager.ToLightTheme();
ApplicationBar = new ApplicationBar();
ApplicationBar.Background = Colors.Yellow;

For some reason the Application Bar is still white, can anyone see what I'm doing wrong?

To keep original style of app bar use:

ThemeManager.OverrideOptions = ThemeManagerOverrideOptions.SystemTrayColors;
ThemeManager.ToLightTheme();

After that you will be able to change background color either from code or xaml.

Use this it could help you:

ThemeManager.ToLightTheme();
ApplicationBar = new ApplicationBar();
ApplicationBar.Background =  Color.FromArgb(0xFF, R, G, B);

put r ,g,b value for yellow color

Just noticed it's BackgroundColor ;

Your method is absolutely right:

ApplicationBar.BackgroundColor = Colors.Yellow;

For RGB it's should be something like:

ApplicationBar.BackgroundColor = Color.FromArgb(0xFF, 246, 254, 64); 

And if you have HTML color you could do::

 string htmlColor = "#f6fe40";
 ApplicationBar.BackgroundColor = Color.FromArgb(255,
                    Convert.ToByte(htmlColor.Substring(1, 2), 16),
                    Convert.ToByte(htmlColor.Substring(3, 2), 16),
                    Convert.ToByte(htmlColor.Substring(5, 2), 16)
                    );

EDIT

look that i found in source files of Theme Manager:

    Colors system trays appropriately and also any set ApplicationBar
    instances. Will not theme ApplicationBar instances that are
    created after the page's Navigated event or that are created and
    not set immediately.

so please try something like this (for example)

void MainPage_Loaded(object sender, RoutedEventArgs e)
        {         
            ThemeManager.ToLightTheme();
            ApplicationBar.BackgroundColor = Colors.Yellow;
        }

Hope this could help worked for me,

ThemeManager.OverrideOptions = ThemeManagerOverrideOptions.None; ThemeManager.ToLightTheme();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM