Search code examples
c#uwpwasm-bindgenuno-platform

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:

enter image description here

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

enter image description here

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}

Solution

  • 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}")