如何更改 Xamarin.Forms UWP 应用程序的强调色? [英] How do I change the accent colour of a Xamarin.Forms UWP application?

查看:16
本文介绍了如何更改 Xamarin.Forms UWP 应用程序的强调色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Xamarin.Forms UWP 应用程序.

I am developing a Xamarin.Forms UWP application.

我正在努力设置应用程序的强调色.这是控件上默认用于某些行为的颜色.

I am struggling to set the accent colour of my application. This is the colour that is used for certain behaviors by default on controls.

例如,Entry 控件在焦点上有一个默认的蓝色突出显示,如下所示:

For example the Entry control has a default blue highlighting on focus shown below:

我从这个线程中尝试了一些建议:在 Windows 中更改强调颜色10 UWP 但似乎没有一个工作.

I have tried a few suggestions from this thread: Change Accent Color in Windows 10 UWP but none seemed to work.

我不确定是不是因为我没有完全理解 Xamarin.UWP 的 UWP 颜色更改有何不同,或者我是否可以使用 Xamarin.Forms 执行此操作.

I am not sure whether it is because I didn't fully understand how changing the colour for UWP differs for Xamarin.UWP, or whether what I'm trying to do is even possible with Xamarin.Forms.

有人知道怎么做吗?

推荐答案

这里FormsTextBox 用于 UWP.

您需要覆盖以下样式颜色:

You need to override below styled colors:

<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundAltHighBrush}" />
<Setter Property="BackgroundFocusBrush" Value="{ThemeResource SystemControlBackgroundChromeWhiteBrush}" />
<Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundChromeDisabledLowBrush}" />

因此,要更改文本框边框画笔的颜色,您可以将这些 ThemeResources 添加到您的 App.xaml 中,如下所示:

So to change the colour of your textbox boarder brush you can add these ThemeResources to your App.xaml like so:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.ThemeDictionaries>
            <ResourceDictionary x:Key="Light">
                <SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="#ff0000" />
            </ResourceDictionary>
        </ResourceDictionary.ThemeDictionaries>
    </ResourceDictionary>
</Application.Resources>

这篇关于如何更改 Xamarin.Forms UWP 应用程序的强调色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆