Change Accent Color in Windows 10 UWP

后端 未结 4 1527
迷失自我
迷失自我 2020-12-07 23:29

I dont really want to use the accent color that the user has chosen in Windows in my app, and instead want to have my own color show. I can change it manually on all the ite

相关标签:
4条回答
  • 2020-12-07 23:43

    What worked for me was setting

     <SolidColorBrush x:Key="SystemAccentColor" Color="#FFCB2128" />
        <Color x:Key="SystemAltHighColor">#FFCB2128</Color>
        <Color x:Key="SystemAltLowColor">#FFCB2128</Color>
        <Color x:Key="SystemAltMediumColor">#FFCB2128</Color>
        <Color x:Key="SystemAltMediumHighColor">#FFCB2128</Color>
        <Color x:Key="SystemAltMediumLowColor">#FFCB2128</Color>
        <Color x:Key="SystemBaseHighColor">#FFCB2128</Color>
        <Color x:Key="SystemBaseLowColor">#FFCB2128</Color>
        <Color x:Key="SystemBaseMediumColor">#FFCB2128</Color>
        <Color x:Key="SystemBaseMediumHighColor">#FFCB2128</Color>
        <Color x:Key="SystemBaseMediumLowColor">#FFCB2128</Color>
    

    In the app.xaml file in order to overwrite the onese set by windows.

    0 讨论(0)
  • 2020-12-07 23:47

    On Win10 UWP, System Accent color is defined as ThemeResource SystemControlHighlightAccentBrush. You can override it as following.

    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Default">
            <SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="Orange" />
        </ResourceDictionary>
        <ResourceDictionary x:Key="Dark">
            <SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="Green" />
        </ResourceDictionary>
        <ResourceDictionary x:Key="Light">
            <SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="Blue" />
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>
    
    0 讨论(0)
  • 2020-12-07 23:56

    Add the following to App.xaml if you are not using any templates or ResourceDictionaries:

    <ResourceDictionary>
        <Color x:Key="SystemAccentColor">#FFCB2128</Color>
    </ResourceDictionary>
    

    If you are using the Minimal Template10 template, then add the following line to Styles/Custom.xaml after the CustomColor and ContrastColor values:

    <Color x:Key="SystemAccentColor">#FFCB2128</Color>
    

    If you have your own ResourceDictionary somewhere else, linked from App.xaml, then similarly add the "Color" line there.

    0 讨论(0)
  • 2020-12-07 23:59

    To change accent color on every system control you have to redefine the system resource as follows.

    Note that SystemAccentColor is a color, not a brush. If you don't redefine all other brushes, the color won't be applied on everything.

    <ResourceDictionary.ThemeDictionaries>
      <ResourceDictionary x:Key="Default">     
        <Color x:Key="SystemAccentColor">#FF20A060</Color>  <!--Your accent color-->
    
        <SolidColorBrush x:Key="SystemControlBackgroundAccentBrush" Color="{ThemeResource SystemAccentColor}" />
        <SolidColorBrush x:Key="SystemControlDisabledAccentBrush" Color="{ThemeResource SystemAccentColor}" />
        <SolidColorBrush x:Key="SystemControlForegroundAccentBrush" Color="{ThemeResource SystemAccentColor}" />
        <SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="{ThemeResource SystemAccentColor}" />
        <SolidColorBrush x:Key="SystemControlHighlightAltAccentBrush" Color="{ThemeResource SystemAccentColor}" />
        <SolidColorBrush x:Key="SystemControlHighlightAltListAccentHighBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.9" />
        <SolidColorBrush x:Key="SystemControlHighlightAltListAccentLowBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.6" />
        <SolidColorBrush x:Key="SystemControlHighlightAltListAccentMediumBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.8" />
        <SolidColorBrush x:Key="SystemControlHighlightListAccentHighBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.9" />
        <SolidColorBrush x:Key="SystemControlHighlightListAccentLowBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.6" />
        <SolidColorBrush x:Key="SystemControlHighlightListAccentMediumBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.8" />
        <SolidColorBrush x:Key="SystemControlHyperlinkTextBrush" Color="{ThemeResource SystemAccentColor}" />
        <SolidColorBrush x:Key="ContentDialogBorderThemeBrush" Color="{ThemeResource SystemAccentColor}" />
        <SolidColorBrush x:Key="JumpListDefaultEnabledBackground" Color="{ThemeResource SystemAccentColor}" />
      </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>
    
    0 讨论(0)
提交回复
热议问题