覆盖应用程序中的强调色 [英] Overwrite Accent Color in App
问题描述
我尝试为我的应用创建自己的设计.主要的事情之一是,我想用我自己的颜色替换强调色.
I try to create a own design for my app. One of the main things is, that I want to replace the accent color with my own color.
现在我可以用这个覆盖画笔了:
Now I can overwrite the brush with this:
<Color x:Key="AppAccentColor">#ff6b53</Color>
<SolidColorBrush x:Key="PhoneAccentBrush" Color="{StaticResource AppAccentColor}"/>
现在,如果我将 PhoneAccentBrush 分配到某个地方,它会显示正确的颜色.但是如果我点击一个文本框,边框仍然是系统设置中设置的颜色的颜色.
Now if I assign the PhoneAccentBrush somewhere it displays the correct color. But if I click on a TextBox the Border is still the Color of the Color set in the system settings.
我也尝试覆盖这些颜色,例如:
I tried to overwrite these colors as well for example with this:
<SolidColorBrush x:Key="PhoneTextBoxEditBorderBrush"
Color="{StaticResource AppAccentColor}" />
但这似乎没有效果.
我还尝试创建一种新样式并复制了我在系统上的 8.1\Design[Theme]\System.Windows.xaml 文件夹中找到的样式.但是在这里他没有找到同一个文件夹中 ThemeResources.xaml 中的不同资源.一旦我也导入了这个,他就不能再构建了.我究竟做错了什么 ?o.O
Also I tried to create a new style and copied the one I found in the 8.1\Design[Theme]\System.Windows.xaml folder on the System. But here he doesn't find different Resources who are in the ThemeResources.xaml in the same folder. As soon as I import this as well he can't build anymore. What am I doing wrong ? o.O
谢谢NPadrutt
推荐答案
在 Windows Phone 8.1 运行时应用程序中,还有另一种覆盖主题颜色的方法.您可以在 App.xaml 文件中执行此操作.以下是更改 TextBox
突出显示边框颜色的示例:
In Windows Phone 8.1 Runtime apps there is another way to override theme colors. You can do it in App.xaml file. Here's example of changing TextBox
highlighted border color:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="TextSelectionHighlightColorThemeBrush" Color="Magenta" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Application.Resources>
您的 TextBox
将如下所示:
And your TextBox
will look like this:
检查您可以通过这种方式覆盖的画笔的完整列表:https://msdn.microsoft.com/en-us/library/windows/apps/dn518235.aspx
Check the full list of brushes you can override this way: https://msdn.microsoft.com/en-us/library/windows/apps/dn518235.aspx
正如您在我的解决方案中看到的,我将其用于 Default 样式.但是您可以为 Light 和 Dark 样式提供不同的选项.
As you can see in my solution, I used it for Default style. But you can have different options for Light and Dark style.
这篇关于覆盖应用程序中的强调色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!