简体   繁体   中英

Cannot Change Accent Color for WASM on Uno 2.4

I defined a new accent color in App.xaml lke this:

Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
            </ResourceDictionary.MergedDictionaries>
            <Color x:Key="SystemAccentColor">#FFCB2128</Color>
            <Color x:Key="AcmGreen">#FFB8C282</Color>
            <Color x:Key="AcmPink">#FFE672A4</Color>
            <Color x:Key="AcmPurple">#FF71749E</Color>
            <Thickness x:Key="PivotItemMargin">0</Thickness>

        </ResourceDictionary>

    </Application.Resources>

It works on UWP app:

在此处输入图像描述

However, Accent Color stays default blue on WASM Page (Edge Chromium - 81.0.416.77)

在此处输入图像描述

The accent color on WASM do not match with UWP version which defined in App.xaml. It should be. How can I fix this?

Nuget Package:

Package Version(s):

  • Uno.UI.RemoteControl {2.4.0}
  • Uno.Wasm.Bootstrap {1.2.0}
  • Uno.Wasm.Bootstrap.DevServer {1.2.0}
  • Microsoft.Extensions.Logging.Filter {1.1.2}
  • Microsoft.Extensions.Logging.Con... {1.1.1}
  • NETStandard.Library {2.0.3}
  • Uno.UI {2.4.0}
  • Microsoft.NETCore.UniversalWindo... {6.2.10}
  • Microsoft.Extensions.Logging.Con... {1.1.1}
  • Microsoft.Extensions.Logging.Filter {1.1.2}
  • Microsoft.UI.Xaml {2.4.0}
  • Uno.Core {2.0.0}

Globally modifying theme colors this way will be supported in Uno soon, when this PR is merged .

For now if you want to modify the color scheme with Uno, you will need to do it per control. For instance for ToggleSwitch you would:

  1. Copy the style for ToggleSwitch into a ResourceDictionary file in your app (typically into a standalone file called ToggleSwitch.xaml ).
  2. Include it in Application.Resources in App.xaml
  3. Modify the part of the style that sets the toggle switch's background. (It looks like this line : Fill="{ThemeResource SystemControlHighlightAccentBrush}" )

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