Override theme brush Windows 10 UWP

前端 未结 2 1226
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-14 02:09

I\'m trying to override some style-colors in Windows 10 but I cannot get it to work.

My app.xaml looks like this:

        
             


        
相关标签:
2条回答
  • 2021-02-14 02:31

    The styles you are setting are for Windows 8 apps. The styles used by Universal Windows apps are greatly simplified.

    The easiest way to find them is to add your ListBox to a page, right click on it in the designer, and select Edit Template... Create a copy of the template and look at the names used.

    All of the controls now use the same brushes when possible rather than having control-specific ones.

    For example, the ListBox uses the following brushes for its Foreground, Background, and BorderBrush:

    • SystemControlForegroundBaseHighBrush
    • SystemControlBackgroundChromeMediumLowBrush
    • SystemControlForegroundBaseHighBrush
    0 讨论(0)
  • 2021-02-14 02:31

    To add to Rob's answer, for those looking for a broader app-wide response, it helped me to find the full default themes, which are available in \(Program Files)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\<SDK version>\Generic folder of a Windows SDK installation, in themeresources.xaml.

    In that is a ResourceDictionary for Default, HighContrast, and Light. The default key handles the Dark theme in UWP, since it is what will be defaulted to when no default "Dark" ResourceDictionary is found.

    The Default and Light themes have nearly 1000 control-specific colors, or more generic "SystemControlForeground..." colors like Rob showed, but in UWP they are mostly based on the following 25 color categories:

    • 24 system colors
    • SystemAccentColor, an OS-wide user-defined color which the UWP docs has a whole page about under Design & UI > Style > Color
      • There's 6 lighter and darker shades of the above (SystemAccentColorLight1, ...Dark1, etc) but they aren't used in the default resource dictionaries. However .6, .8 and .9 opacities of that color are used a handful of times, the only time opacities are used.

    Then there are the 300+ color categories from Windows 8.1 that are left in, which manually pick a specific color, the extent of which you can see here

    The only exception to the above is that the InkToolBar styling is almost exclusively derived from the High Contrast colors.

    The High Contrast theme, pulls heavily from 8 additional System[blank]Colors that, similar to the SystemAccentColor, are OS-wide values. They're defined by templates and/or the user if they chose a High Contrast theme, which is an option Windows 10 has in its personalization settings. High Contrast is also an accessibility feature, so I think I'll be avoiding overriding that ResourceDictionary, no matter the app branding.

    But effectively, by overriding the SystemAccentColor and the 24 System[blank]Colors in the XAML framework, you can effect the change of hundreds of specific color choices in a consistent way across an app.

    0 讨论(0)
提交回复
热议问题