Overwrite Accent Color in App

瘦欲@ 提交于 2019-12-12 04:48:34

问题


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}"/>

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}" />

But this seems to have no effect.

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

Thanks NPadrutt


回答1:


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>

And your TextBox will look like this:

Check the full list of brushes you can override this way: https://msdn.microsoft.com/en-us/library/windows/apps/dn518235.aspx

As you can see in my solution, I used it for Default style. But you can have different options for Light and Dark style.



来源:https://stackoverflow.com/questions/28562483/overwrite-accent-color-in-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!