我正在开发一个 Xamarin.Forms
UWP 应用程序。
我正在努力设置我的应用程序的强调色。这是默认情况下在控件上用于某些行为的颜色。
例如,Entry 控件在焦点上有一个默认的蓝色突出显示,如下所示:
我尝试了这个线程的一些建议:Change Accent Color in Windows 10 UWP但似乎都不起作用。
我不确定这是否是因为我没有完全理解改变 UWP 的颜色与 Xamarin.UWP 有何不同,或者我正在尝试做的事情是否可以通过 Xamarin.Forms 实现。
有人知道怎么做吗?
最佳答案
Here是FormsTextBox的样式代码用于 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/