Cannot Change Accent Color for WASM on Uno 2.4

[亡魂溺海] 提交于 2021-01-28 05:35:14

问题


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}

回答1:


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


来源:https://stackoverflow.com/questions/61889917/cannot-change-accent-color-for-wasm-on-uno-2-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!