问题
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:
- Copy the style for ToggleSwitch into a
ResourceDictionary
file in your app (typically into a standalone file calledToggleSwitch.xaml
). - Include it in
Application.Resources
inApp.xaml
- 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