简体   繁体   English

启用浅色主题时更改应用程序栏上的背景

[英]Change background on applicationbar when light theme is on

Hi i have this problem with my applicationbar. 嗨,我的我的应用程序栏有这个问题。 When i change the theme to light the icons turns to black, can I prevent this or can I change the backgroundcolor to something else when light theme is on. 当我将主题更改为浅色时,图标变为黑色,当打开浅色主题时,可以防止这种情况还是可以将背景色更改为其他颜色。

Now i have a purple background all the time so either change the icons or background. 现在,我一直都有紫色背景,因此请更改图标或背景。

Any ideas for this? 有什么想法吗?

For Detect the Dark or Light theme color, you can use 对于检测深色或浅色主题颜色,可以使用

bool DarkThemeUsed ()
{ 
     return Visibility.Visible ==   (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"];
}

bool LightThemeUsed() 
{
     return Visibility.Visible == (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"];
}

Source is developer.nokia.com : On this website, you've many idea and solution for little problem on windows phone :D 来源是developer.nokia.com :在此网站上,您对Windows Phone上的小问题有很多想法和解决方案:D

You can just test if your phone use the dark or the light them just when you started your application ( on your App.xaml.cs): 您可以仅在启动应用程序时(在App.xaml.cs上)测试手机是使用深色还是浅色:

private void Application_Launching(object sender, LaunchingEventArgs e)
{
    DetectUserTheme();
}

private void DetectUserTheme()
{
    if(LightThemeUsed())
    {
        // Adapt your icons, background for the light theme.
        return;
    }

    // Adapt your icons, background for the dark theme. 
}

You can also use the color accent, define by the user : 您还可以使用由用户定义的颜色强调:

 Color currentAccentColorHex = 
        (Color)Application.Current.Resources["PhoneAccentColor"];

And you can use it in your application for few color text or element... 而且您可以在应用程序中使用它来显示少量彩色文本或元素...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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