【问题标题】:Setting the Accent Color does not work when using Microsoft.UI.Xaml.Controls使用 Microsoft.UI.Xaml.Controls 时设置强调色不起作用
【发布时间】:2021-12-11 16:08:17
【问题描述】:

我创建了一个空白的 UNO 平台应用程序,并向 MainPage.xaml 添加了一些控件(ListView、Button、ComboBox 和 CheckBox)。看起来是这样的:

现在我想更改颜色,因此我尝试在我的 App.xaml 中覆盖强调色:

<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"  />
                <!-- Place resources here -->
            </ResourceDictionary.MergedDictionaries>

            <Color x:Key="SystemColorHighlightColor">#E64A19</Color>
            <Color x:Key="SystemAccentColor">#E64A19</Color>
            <SolidColorBrush x:Key="SystemColorControlAccentBrush" Color="{StaticResource SystemAccentColor}" />
            
        </ResourceDictionary>
</Application.Resources>

但它不起作用。如何更改强调色?

【问题讨论】:

  • 找到解决方案了吗?

标签: uwp uno-platform


【解决方案1】:

覆盖浅色和深色主题的系统颜色可以解决问题:

<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"  />
                <!-- Place resources here -->
            </ResourceDictionary.MergedDictionaries>
            <Color x:Key="SystemAccentColorLight1">#FF0000</Color>
            <Color x:Key="SystemAccentColorLight2">#FF0000</Color>
            <Color x:Key="SystemAccentColorLight3">#FF0000</Color>
            <Color x:Key="SystemAccentColorDark1">#FF0000</Color>
            <Color x:Key="SystemAccentColorDark2">#FF0000</Color>
            <Color x:Key="SystemAccentColorDark3">#FF0000</Color>
       </ResourceDictionary>
</Application.Resources>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-15
    • 2017-06-25
    • 1970-01-01
    • 2023-03-24
    • 2022-06-23
    • 1970-01-01
    • 2019-08-23
    相关资源
    最近更新 更多