Override theme brush Windows 10 UWP

前端 未结 2 1227
佛祖请我去吃肉
佛祖请我去吃肉 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

    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\\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.

提交回复
热议问题