c# - 如何更改 Xamarin.Forms UWP 应用程序的强调色?

标签 c# xamarin xamarin.forms uwp windows-10-universal

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

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

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

enter image description here

我尝试了这个线程的一些建议:Change Accent Color in Windows 10 UWP但似乎都不起作用。

我不确定这是否是因为我没有完全理解改变 UWP 的颜色与 Xamarin.UWP 有何不同,或者我正在尝试做的事情是否可以通过 Xamarin.Forms 实现。

有人知道怎么做吗?

最佳答案

HereFormsTextBox的样式代码用于 UWP。

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

<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 中,如下所示:

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

关于c# - 如何更改 Xamarin.Forms UWP 应用程序的强调色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38050302/

相关文章:

c# - 尝试获取 instagram API

c# - EntityFramework 5 - 已检测到对关系 'x' 的角色 'x' 的冲突更改

c# - Xamarin mediaPicker.TakePhotoAsync 使应用程序崩溃

c# - 如何使用 android 在 Xamarin 中获取根布局?

c# - 使用 .NET 的 Xamarin iOS 本地化

Xamarin Forms 在 iOS 上隐藏按钮并在 Android 上显示它

c# - 使用 ExitWindowsEx 时,注销有效,但关机和重新启动无效

c# - 如何使用asp.net c#根据用户输入查询oracle数据库

listview - iOS 上的无限 ListView 刷新后跳转到第一项

c# - 告诉 ActivityIndi​​cator 显示自己,然后导航到另一个页面